Copy Excel Sheet using Apache POI

China☆狼群 提交于 2019-12-09 09:11:58

问题


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);
            }


来源:https://stackoverflow.com/questions/6992104/copy-excel-sheet-using-apache-poi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!