I’m having problems when copying a worksheet from one workbook to another workbook.
If I copy the worksheet a second time into the new workbook, the chart uses the data from the first worksheet.
I found this post which describes a problem similar to the one I’m having but on the .NET version of Aspose Cells:
I am attaching an archive in which there is an example file as well as the result obtained with the following code:
String excelFileName = "test_excel_vente_composants_test_graphiques.xlsx"; Workbook wb = new Workbook(excelFileName); Workbook copyWb = new Workbook(); copyWb.getWorksheets().clear(); CopyOptions copyOptions = new CopyOptions(); copyOptions.setReferToDestinationSheet(true); Worksheet copyWs = copyWb.getWorksheets().add("Test_1"); copyWs.copy(wb.getWorksheets().get(0), copyOptions); copyWs = copyWb.getWorksheets().add("Test_2"); copyWs.copy(wb.getWorksheets().get(0), copyOptions); copyWb.save(excelFileName.substring(0, excelFileName.length() - 5) + "_updated.xlsx");
tests.zip (28.1 KB)
You will see that in the “Test_2” tab, the chart data points to the “Test_1” tab.
You will also find that the print area is not correctly defined in the “Test_2” tab, while it is correct in the “Test_1” tab.
Thanks in advance for your help, regards,