is it possible to change sheet name with apache poi MS excel java android

39,640

Solution 1

The following should do the trick:

workbook.setSheetName(workbook.getSheetIndex(sheet), "newName");

Solution 2

If you already know the sheet index, simply call

workbook.setSheetName(sheet-index, "my sheet name");

where sheet-index is the sheet number (0 based)

Share:
39,640
funfordevelopping
Author by

funfordevelopping

Updated on October 10, 2021

Comments

  • funfordevelopping
    funfordevelopping over 2 years

    is there any way to update existing sheet name of MS Excel file knowing that I am using apache poi in my android app

    I can create a sheet with my custom name

    HSSFSheet sheet = workbook.createSheet("my custom name");
    

    but when I want to copy another sheet to this one , the name also is copied and my custom name is crashed