I get an error when trying to open the excel document into which I copied the sheets:
Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.
Removed Records: Object from /xl/worksheets/sheet1.xml part
Removed Records: Object from /xl/worksheets/sheet2.xml part
Code:
Workbook templateBook = new Workbook(classLoader.getResourceAsStream("usn.xls"));
Workbook destinationBook = new Workbook();
CopyOptions copyOptions = new CopyOptions();
for (int i = 0; i < 2; i++) {
Workbook workbook = new Workbook();
workbook.copy(templateBook);
Worksheet sourceSheet = workbook.getWorksheets().get(0);
Worksheet destinationSheet = i == 0 ? destinationBook.getWorksheets().get(0) : destinationBook.getWorksheets().add("sheet" + (i + 1));
destinationSheet.copy(sourceSheet);
PageSetup pageSetup = destinationSheet.getPageSetup();
pageSetup.copy(sourceSheet.getPageSetup(), copyOptions);
pageSetup.setPrinterSettings(null); // Or I get an error "Removed Records: Object from /xl/printerSettings/printerSettings1.bin part (Print options)"
workbook.dispose();
}
destinationBook.save("D:/Temp/SmartMarkersTest.xlsx");
destinationBook.dispose();
templateBook.dispose();
error_screenshot1.png (16.3 KB)
error_screenshot2.png (22.6 KB)
source_document.zip (15.7 KB)
aspose-cells version 20.4
java version 1.8.0_144