Hi, I have an issue.
When I try insert row/column with the object InsertOption
this work fine with the insertRows()
but not with insertColumns()
.
Workbook workbook = new Workbook("cicciofessa.xlsx"); Worksheet worksheet = workbook.getWorksheets().get(0);
InsertOptions options = new InsertOptions();
options.setCopyFormatType(CLEAR);
System.out.println(options.getCopyFormatType());
worksheet.getCells().insertColumns(3,1, options);
worksheet.getCells().insertRows(6,1, options);
workbook.save("cicciofessa.xlsx");
InsertOprions.PNG (10.2 KB)
The version is 25.4
@PietroTGK,
Thanks for the screenshot and code snippet.
Could you please zip and attach input Excel file “cicciofessa.xlsx”. We will check your issue soon.
@PietroTGK,
I checked your Excel file and tested your code snippet. Apparently, Aspose.Cells works as expected and it works the same way as MS Excel does. If you could perform your task in MS Excel, i.e., insert a blank column at D (column), the borders/formatting would be retained for the newly inserted column. For confirmation, open your input Excel file into MS Excel manually. Now select column D (by clicking on D header via mouse pointer), then right-click on it to select/click “Insert”. You will notice the same display/thing which was performed by Aspose.Cells APIs via insertColumns method. For your needs, you can insert cut/copy a blank (cells) range onto it. For example, you may create a range based on blank (non-formatted) cells which do not have borders/formatting, e.g., E6:E17. For your needs, you may try the workaround and simply replace the line of code from your code segment:
i.e.,
worksheet.getCells().insertColumns(3,1, options);
with:
Range range1 = worksheet.getCells().createRange("E6:E17");
worksheet.getCells().insertCutCells(range1,5,3,ShiftType.RIGHT);
it will work fine and as per your expectations.
@PietroTGK
By testing on the latest version v25.4 using sample files and code, we can reproduce the issue. Cells.insertColumns() does not work fine with InsertOptions parameter CopyFormatType.CLEAR.
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-46354
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.
@PietroTGK,
We are pleased to inform you that your issue (Ticket ID: “CELLSJAVA-46354”) has been resolved, so you don’t have to use the workaround. The fix/enhancement will be included in an upcoming release (Aspose.Cells v25.5) that we plan to release in the first half of May 2025. You will be notified when the next version is released.
1 Like