How to copy one entire Excel sheet into another Excel sheet of the same workbook, using Java SE and Apache POI?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You'll probably want the cloneSheet(sheetNumber) method on the Workbook. See the JavaDocs for details
回答2:
Did you check the API?
to copy a sheet into the same workbook, use
HSSFWorkbook.clonesheet(int sheetIndex)
Ivan's comment has linked the question for copying across workbooks.
回答3:
Yes , this can be...Here my code.
XSSFWorkbook workbook = new XSSFWorkbook(file);
int totalRecords = 5;
for (int i = 0; i < totalRecords - 1; i++) {
workbook.cloneSheet(1);
}
for (int i = 1; i <= totalRecords; i++) {
workbook.setSheetName(i, "S" + i);
}