Hi,
Using Aspose Cells for Java, version 25.9.
Sample code:
Workbook workbook = new Workbook("input.xlsx");
Worksheet worksheet = workbook.getWorksheets().get("IT Projections");
Cells cells = worksheet.getCells();
cells.insertColumns(3, 7);
cells.copyColumns(cells, 2, 3, 7);
workbook.save("output.xlsx");
In the code above, we are asking Aspose Cells to insert 7
additional columns.
Following that, we copy the content from sourceColumnIndex
2
to the newly inserted columns:
cells.copyColumns(cells, 2, 3, 7);
If you look at the generated result, it seems that with each column progressing to the right, more and more formatting details get lost. In the attached zip file, I’ve included inconsistencies on copied columns.png
highlighting some of them
Kind regards,
Taras
details.zip (402.3 KB)
@TarasTielkes
It seems that you’re experiencing issues with formatting when using the copyColumns
method in Aspose Cells for Java. This can occur due to how the method handles formatting during the copy operation, particularly when multiple columns are involved.
To address this, you might want to try copying the columns one at a time or using a loop to ensure that formatting is preserved. Here’s a modified version of your code that demonstrates this approach:
Workbook workbook = new Workbook("input.xlsx");
Worksheet worksheet = workbook.getWorksheets().get("IT Projections");
Cells cells = worksheet.getCells();
cells.insertColumns(3, 7);
// Copy each column individually to preserve formatting
for (int i = 0; i < 7; i++) {
cells.copyColumns(cells, 2, 3 + i, 1);
}
workbook.save("output.xlsx");
By copying each column from the source to the destination one at a time, you may retain the formatting better than copying all at once.
If the issue persists, consider checking the specific formatting settings of the source columns and applying them manually to the destination columns after copying.
Feel free to reach out if you have further questions!
@TarasTielkes,
Thanks for the template Excel file, screenshot and sample code snippet.
After initial testing, I am able to reproduce the issue as you mentioned by using your template Excel file and sample code snippet. I found Cells.copyColumns results in incomplete formatting or lost formatting.
We require thorough evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSJAVA-46507
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@TarasTielkes,
This is to inform you that your issue (Ticket ID: “CELLSJAVA-46507”) has been resolved. The fix/enhancement will be included in the upcoming release (Aspose.Cells v25.10) that we plan to release in the first half of October 2025. You will be notified in this thread once the new version is published.