When insert columns cell validation is copied

Hi everyone!
I insert new columns like this:
worksheet.getCells().insertColumns(int columnIndex, int totalColumns, boolean updateReference);
U can find the example project here: GitHub - zeroWiNNeR/aspose-cells-insert-columns-error

This works fine, almost. Columns are created, values are not copied. However, the validation and cell styles is copied from the previous column as I found out empirically.
Can anyone tell me is it a bug or normal behavior?
Thanks!

@zerowinner
This is normal behavior, consistent with manually inserting columns in Excel. Please refer to the attachment. result.zip (12.9 KB)

The sample code as follows:

Workbook workbook = new Workbook(filePath + "example_copy_validation_range.xlsx");
Worksheet worksheet = workbook.getWorksheets().get(0);

worksheet.getCells().insertColumns(2, 2);
workbook.save(filePath + "out_java.xlsx");
1 Like

@zerowinner,

Please note that normal cell values/data are not copied when inserting new columns. This is the same behavior as MS Excel when inserting new columns. Either you can use the Range.copy() method if you are copying data from other cell ranges to your newly inserted column cell(s), or you have to insert values via Cell.putValue() or Cell.setValue() method into the new cells accordingly.

1 Like