0

I'm trying to update from an Apache POI dependency to the latest (5.2.3) and I can't seem to find a way of getting the BlipFill from a XSLFTableCell. Currently the new XSLFTableCell has a .getFillPaint() that returns a PaintStyle instance, whose class has a BlipFill static inner class but that's not accessible. Before we would get the TcPr from a table cell xml object but that's not longer possible. Is this a gap in the current POI version or is there's another way around it?

The code in question is more or less the answer here: How to add image to PowerPoint ppt table cell using apache POI hslf/xslf?

More exactly trying to do this:

CTBlipFillProperties blipPr = (XSLFTableCell cell).getXmlObject().getTcPr().addNewBlipFill();
Kein H
  • 1
  • 1
    https://stackoverflow.com/questions/73537742/is-there-any-way-to-add-images-into-ppt-table-cell-using-apache-poi/73543221#73543221 - Just tested. Works using `apache poi 5.2.3`. – Axel Richter Apr 07 '23 at 15:27
  • 1
    Needs `poi-ooxml-full.jar`, see https://poi.apache.org/help/faq.html#faq-N10025 – Axel Richter Apr 07 '23 at 15:37
  • @AxelRichter Could you share a pom? I added the poi-ooxml-full ver 5.2.3, and running with xml beans 5.1.1 and poi 5.2.3, and maven still fails to compile with errors like "cannot find symbol", nor do I see a function to get the TcPr of a cell. – Kein H Apr 07 '23 at 16:09
  • Me not using maven. But you need `poi-ooxml-full` **additionally**. So `poi-ooxml` **and** `poi-ooxml-full`, always both of same version. – Axel Richter Apr 07 '23 at 16:13
  • @AxelRichter I just verified, I have both poi-ooxml and poi-ooxml-full, same version, and and after fixing my code a bitit works (forgot I needed to cast the xml object to the right XML class) Thanks for the quick responses! – Kein H Apr 07 '23 at 16:31
  • Yes, casting is necessary since Apache Poi version 3.13 (since 2015!). Versions before had overwritten method `getXmlObject` to return appropriate `CT*`-classes. From Apache Poi version 3.13 on `getXmlObject` only returns `org.apache.xmlbeans.XmlObject`. – Axel Richter Apr 08 '23 at 06:29
  • Thanks @AxelRichter ! I'm updating a lot of code from poi 3.12, now we suddenly have a need for newer version features due to new requirements. I was wondering if you know of an article or a blog post that explains the details of the version changes more? The changelog wasn't very useful and I'm now running into another issue where XSLFTable::getNumberOfRows doesn't match XSLFTable::getRows().sizeI() – Kein H Apr 17 '23 at 04:53
  • No, I do not know such article. But [XSLFTable.getNumberOfRows](https://svn.apache.org/viewvc/poi/tags/REL_5_2_3/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTable.java?view=markup#l120) and [XSLFTable.getRows](https://svn.apache.org/viewvc/poi/tags/REL_3_12_FINAL/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java?view=markup#l106)`.size()` is not the same. – Axel Richter Apr 17 '23 at 05:56
  • The first gets size of TR array from `CTTable` while the other gets size of `List`. That might differ if a row was added only into underlying `CTTable` without updating the `List`. But that has not changed since version 3.12. – Axel Richter Apr 17 '23 at 05:56
  • That's very weird, I've double checked the ppt presentation and the table rows is much higher than the ones being reported by XSLFTable.getNumberOfRows, I've even recreated the table multiple times. I should report this on the apache poi bug list right? – Kein H Apr 17 '23 at 13:40
  • "I should report this on the apache poi bug list right?": Yes. But that only will be successfully together with a [SSCCE](http://www.sscce.org/). Most of the time you find the cause of the issue yourself while creation a such. If not, you could ask a question providing that SSCCE aka [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) here. – Axel Richter Apr 17 '23 at 15:16
  • Thanks! I will do some extra verification and then file a bug if it's indeed apache poi at fault. Thanks for all the help and info Alex. – Kein H Apr 17 '23 at 16:51

0 Answers0