Using Aspose Cells for Java 19.7.
Workbook source = new Workbook("table_copy_test.xlsx"); Worksheet sourceSheet = source.getWorksheets().get(0); Cells sourceCells = sourceSheet.getCells(); Workbook target = new Workbook(); Worksheet targetSheet = target.getWorksheets().get(0); targetSheet.getCells().copyColumns(sourceCells, 0, 0, 2); target.save("result.xlsx");
table_copy_test.zip (7.4 KB)
Comparing the source and result workbooks, there are a number of differences:
- The background color of style “STYLE2” has changed
- The table name has been reverted to “Table1”
- The formula has been changed from a calculated column formula to a regular formula
Our use case is very simple: we need to copy a sheet or range of cells that contains one of more Excel tables. We expect the copied result to be fully consistent with the source table definition.
Thanks in advance,