We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Slow copy with conditional formatting

Hi.
I have a problem after upgrading aspose-cells from version 21.3 to 22.4.
In my case I must copy ranges one by one from Sheet1 to Sheet3. Next, do something with data. Then I must copy back from Sheet3 to Sheet1. Each range contains Conditional Formatting.
Until version 21.3 it works fast. But in version 22.4 each copy and save slows down. For example, in test (for 10 ranges) execution time is 150 ms for version 21.3. For version 22.4 it takes 5000 ms.

@Test
void copyRangeWithConditionalFormatting() throws Exception {
    Workbook workbook = new Workbook("C://test.xlsx");
    try {
        // we have some rows for copy
        List<String> cellAddresses = List.of("A14:AA14", "A18:AA18", "A22:AA22", "A26:AA26", "A32:AA32", "A36:AA36", "A41:AA41", "A44:AA44", "A47:AA47", "A50:AA50");
        Cells cells = workbook.getWorksheets().get(0).getCells();
        Cells cells2 = workbook.getWorksheets().get(2).getCells();
        for (String cellAddress : cellAddresses) {
            // copy to Sheet3
            Range source = cells.createRange("Sheet1!" + cellAddress);
            Range range = cells2.createRange("Sheet3!" + cellAddress);
            PasteOptions options = new PasteOptions();
            options.setPasteType(PasteType.ALL);
            range.copy(source, options);
            // and copy back to Sheet1
            source = cells2.createRange("Sheet3!" + cellAddress);
            range = cells.createRange("Sheet1!" + cellAddress);
            range.copy(source, options);
        }
        workbook.save("C://test_result.xlsx");
    } catch (Exception e) {
        throw new AsposeBookException(e);
    }
}

In additional, I check this behavior starts from version 21.4.
When I remove all Conditional Formatting it works fast.

test.zip (14.6 KB)

@MasteRMR,

Thanks for the template file.

Please notice, I found the issue as you mentioned by using your template file. I found copy operation is relatively slow with conditional formatting on the cells using newer versions. I have logged a ticket with an id “CELLSJAVA-44609” for your issue. We will look into it soon.

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

@MasteRMR,

This is to inform you that your issue has been resolved now. The fix will be included in the next release (Aspose.Cells for Java 22.6) which is scheduled in the second week of June 2022. You will also be notified when the next version is released.