// Create a new workbook Workbook workbook = new Workbook(); //Load template file AgingReport.xlsx from resource InputStream fileStream = this.getResourceStream("xlsx/AgingReport.xlsx"); workbook.open(fileStream); //Copy the active sheet to the end of current workbook IWorksheet copy_worksheet = workbook.getActiveSheet().copy(); copy_worksheet.setName("Copy of " + workbook.getActiveSheet().getName()); // Save to an excel file workbook.save("CopyWorksheet.xlsx");
// Create a new workbook var workbook = Workbook() //Load template file AgingReport.xlsx from resource val fileStream = this.getResourceStream("xlsx/AgingReport.xlsx") workbook.open(fileStream!!) //Copy the active sheet to the end of current workbook val copy_worksheet = workbook.activeSheet.copy() copy_worksheet.name = "Copy of " + workbook.activeSheet.name // Save to an excel file workbook.save("CopyWorksheet.xlsx")