Apache POI SS - Copy Sheet Within Workbook

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

For More Examples, Please Visit Aspose Docs

Last edited May 14, 2014 at 10:34 AM by shoaibkhan, version 4