Delete Column from a XSLFTable

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Delete Column from a XSLFTable

jsaunders2011@gmail.com
I need to delete a column from a table in a PPT slide. I don't see an method on XSLFTable that will allow me to do this.  I've experimented extensively with this, but it doesn't work properly:

                         CTTableGrid tableGrid = table.getCTTable().getTblGrid();
    CTTableCol[] columns = tableGrid.getGridColArray();
    columns = ArrayUtils.remove(columns, columnIndexToDelete);
    tableGrid.setGridColArray(columns);

It always seems to delete the last column of the table, regardless of the index passed in.
I've also tried this:

    table.getCTTable().getTblGrid().removeGridCol(columnIndexToDelete);

It results in the same behavior. Any suggestions?

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Delete Column from a XSLFTable

kiwiwings
I've prepared an example on how to delete a column - does it work for you?:
https://pastebin.com/AVNTX9yJ

... and yes, I guess this should be inside the API and a few package access methods made public.
I think I haven't yet made the setGridSpan & Co. methods public, as I wanted to have an implementation for HSLF too.

Andi.


signature.asc (495 bytes) Download Attachment