是否有可能用apache poi MS excel java android更改工作表名称

时间:2023-01-27 20:25:34

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

有没有办法更新MS Excel文件的现有工作表名称知道我在我的Android应用程序中使用apache poi

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

但是当我想将另一张表复制到此表时,该名称也会被复制并且我的自定义名称会崩溃

2 个解决方案

#1


48  

The following should do the trick:

以下应该做的伎俩:

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

#2


1  

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)

其中sheet-index是工作表编号(基于0)

#1


48  

The following should do the trick:

以下应该做的伎俩:

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

#2


1  

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)

其中sheet-index是工作表编号(基于0)