On 2018/05/11 14:30:44, Andreas Beeker <[email protected]> wrote: 
> > What is the proper way to delete a row from an XSLFTable?
> 
> If you aren't modify the table instance further, you can use 
> getCTTable().removeTr(index):
> 
> // prepare some data
> 
> ByteArrayOutputStream bos = new ByteArrayOutputStream(50000); try 
> (XMLSlideShow ppt = new XMLSlideShow()) {
>     XSLFTable tab = ppt.createSlide().createTable(5, 5); for (int y = 0; y < 
> 5; y++) {
>         for (int x = 0; x < 5; x++) {
>             tab.getCell(y, x).setText(y + "" + x); }
>     }
>     ppt.write(bos); }
> 
> // remove a row
> 
> try (XMLSlideShow ppt = new XMLSlideShow(new 
> ByteArrayInputStream(bos.toByteArray())); FileOutputStream fos = new 
> FileOutputStream("test.pptx")) {
>     XSLFTable tab = (XSLFTable)ppt.getSlides().get(0).getShapes().get(0); 
> tab.getCTTable().removeTr(3); ppt.write(fos); }
> 
> 
> Andi
> 
> 


getCTTable().removeTr(index) results in the same exception being thrown. I need 
to delete 100+ table rows in a single powerpoint, many of them in the same 
table. It isn't practical for me to save the file after every row delete


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

Reply via email to