Free Support Forum - aspose.com

Java, ListObject -> getListColumns -> Insert new column by index

Hello, I am trying to manipulate the Excel file that has a table (ListObject).
Lets say I have a table with 10 columns and I want to add a new column at index 5. The new table would have 11 columns.

Is there an API for this? The only think I saw is:

table.getListColumns().add("col1");

This returns the index, but it will be added at the end of the table.

Thanks

@eyalmolad,

Please simply try to use Cells.insertColumn() method to insert your column at your desired location accordingly. Also, you need to use ListObject.resize() method to update its range/area accordingly.

Thanks. The reason I tried the table.getListColumns().add("col1"); function is because of this:

the cells.deleteColumn stopped working in 21.3.

@eyalmolad,

You are welcome. We have now logged appropriate ticket for your other issue you posted in the thread. You may follow up the thread for latest updates and for fix.