Free Support Forum - aspose.com

The broken document is saved after copying the sheets

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

@Gornostaev,

Thanks for the template file, sample code, screenshots and details.

After an initial test, I am able to observe the issue as you mentioned by using your sample code with your template file. I found the output document is broken after copying the sheets. By the way, the output file is opened fine into MS Excel 2007 but MS Excel 2010/2013 or greater version prompts error messages as you mentioned. Anyways, I have logged a ticket with an id “CELLSJAVA-43171” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

1 Like

@Gornostaev,

This is to inform you that we have fixed your issue now. We will shortly provide you the fixed version after performing QA and incorporating other enhancements and fixes.

1 Like

@Gornostaev,

Please try our latest version/fix: Aspose.Cells for Java v20.4.3 (attached)

Your issue should be fixed in it.

Let us know your feedback.
aspose-cells-20.4.3-java.zip (7.0 MB)

That helped. Thank you very much!

@Gornostaev,

Good to know that your issue is sorted out by the new fix/version. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

The issues you have found earlier (filed as CELLSJAVA-43171) have been fixed in Aspose.Cells for Java v20.5. This message was posted using Bugs notification tool by ahsaniqbalsidiqui