We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cannot get first portion from empty cell in Aspose.Slides for Java v18.8

I have an existing PPTX slide that contains a table with empty cells that have specific text formatting set on them.

When using Aspose.Slides for Java version 16.11.0 the following bit of code works fine on the empty cells and the text is added with the correct formatting as defined on the cell:

someEmptyTableCell.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).setText(“Hello World!”)

However, when using Aspose.Slides for Java version 18.8 the same code does not work and fails at


and I get an exception that says that the index is invalid. This sort of makes sense because when looking more closely at it I can see that


returns an empty collection.

Yet, this used to work fine in version 16.11.0 and I don’t understand why it does not work anymore, so could you please let me know if this is a bug or if there is some workaround, thanks.


I have observed your comments. Can you please share source files and complete sample project so that we may further investigate to help you out.


Thank you for your response. I am having this issue on a commercial project where we are looking to upgrade from version 16.11.0 to the latest version which currently is 18.8. The code base is quite extensive and being a commercial project I am afraid I cannot share the source code. However, I can share the PPTX where we are experiencing this issue: block-table.zip (51.4 KB). I have also updated/corrected the code snippets in my original post as I noticed they contained an error.

On upgrading to an up to date version we are also looking to renew/upgrade our commercial licence but I am afraid we cannot do that until we have full confidence that the latest version does not create more issues than it solves.


I have observed the presentation file shared by you and request you to please provide a working sample code reproducing the issue as from the code line share by you it is not getting clear that exception is raised for which cell of row.

Please find attached a sample project that attempts to read the first portion of an empty cell in the PowerPoint slide I have sent you before.

The project includes the Java source code and the PowerPoint slide, but does not include the Aspose.Slides library nor a licence file as I assume you will be able to add these on your side for testing. The source code expects to find the license file in the root directory of the project.

AsposeSlidesTest.zip (52.5 KB)


I have observed the issue shared by you and like to share that there is no content inside the table cells and table portions are empty by design. I suggest you to please try using following modified code on your end.

public static void TestPortion()

    String path="C:\\AsposeSlidesTest\\AsposeSlidesTest\\";
    Presentation presentation = new Presentation(path+"block-table.pptx");

    ISlide slide = presentation.getSlides().get_Item(0);

    Table table = null;

    for (IShape shape : slide.getShapes()) {
        if (shape instanceof Table) {
            table = (Table) shape;

    if (table == null) {
        System.err.println("No table was found on the slide.");

    ICell cell = table.get_Item(0, 0);

    IPortionCollection cellPortions = cell.getTextFrame().getParagraphs().get_Item(0).getPortions();

    System.out.println("Number of portions found: " + cellPortions.getCount());

    IPortion firstPortion = null;

    try {
        firstPortion = cellPortions.get_Item(0);
    } catch (Exception e) {
        IPortion port=new Portion("");
        firstPortion = cellPortions.get_Item(0);

    firstPortion.setText("Aspose.Slides for Java 16.11.0 rocks!");

    System.out.println("\nFirst portion of empty cell was retrieved successfully.\n");
    System.out.println("Text content in first portion of empty cell is: \"" + firstPortion.getText() + "\"");

I am afraid that your answer is not satisfactory.

First and foremost, my sample code is tried and tested on Aspose.Slides 16.11.0 and it works perfectly without triggering an exception, so please DO test it in that older version to satisfy yourself that this is correct.

Moreover, your solution (which I already figured out myself before writing on this forum) has the fundamental flaw that by adding a newly created portion instance, the existing formatting in the cell is lost. PowerPoint does support setting formatting in empty cells and as such Aspose.Slides should be able to place content in empty cells while maintaining the existing formatting, a feature that works absolutely fine in Aspose.Slides 16.11.0 but that seems to have been broken in the latest versions, which leads me to believe that this is a bug and is not by design so please do check that. In the worst case scenario there should be a way to get the existing formatting from an empty cell and apply it again once the new portion has been added, although this approach would be less than ideal.


I have observed your feedback. An issue with ID SLIDESJAVA-37329 has been created in our issue tracking system to further investigate the issue on our end that whether 18.8 behavior is wrong or older version. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Thank you for your response.

The issues you have found earlier (filed as SLIDESJAVA-37329) have been fixed in this update.