Wiki

Clone wiki

Aspose for Apache POI / Copy-Sheet-Within-Workbook

Apache POI SS

Workbook wb = new HSSFWorkbook();
wb.createSheet("new sheet");
wb.createSheet("second sheet");
Sheet cloneSheet = wb.cloneSheet(0);

// now you have to manually copy all the data into new sheet from the cloneSheet

Aspose.Cells

//Create a new Workbook by excel file path
Workbook wb = new Workbook("data/workbook.xls");

//Create a Worksheets object with reference to the sheets of the Workbook.
WorksheetCollection sheets = wb.getWorksheets();

//Copy data to a new sheet from an existing sheet within the Workbook.
sheets.addCopy("Sheet1");

//Save the excel file.
wb.save("data/AsposeCopyWorkbook.xls");

Download Source Code

Updated