Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Jan 13, 2025 4:41 pm

Hi we getting:
Code: Select all
java.lang.NullPointerException: Cannot invoke "com.spire.doc.DocumentObject.spr┢⅕(int)" because "tableContainer" is null
   at com.spire.doc.packages.sprlgz.spr╹“—(Unknown Source)
   at com.spire.doc.packages.sprcqz.spr⅖®—(Unknown Source)
   at com.spire.doc.packages.sprlgz.spr╃“—(Unknown Source)
   at com.spire.doc.packages.sprlgz.spr┵“—(Unknown Source)
   at com.spire.doc.packages.sprlgz.spr┺“—(Unknown Source)
   at com.spire.doc.Table.spr—≂—(Unknown Source)
   at com.spire.doc.Table.spr┦≂—(Unknown Source)
   at com.spire.doc.packages.sprgzca.spr╃┆—(Unknown Source)
   at com.spire.doc.packages.sprvuca.spr⅞┅—(Unknown Source)
   at com.spire.doc.packages.sprvuca.spr⅚┆—(Unknown Source)
   at com.spire.doc.packages.sprvuca.spr†┈—(Unknown Source)
   at com.spire.doc.packages.sprvuca.spr┨┈—(Unknown Source)
   at com.spire.doc.packages.sprvuca.spr┕┇—(Unknown Source)
   at com.spire.doc.packages.sprvuca.spr┨┈—(Unknown Source)
   at com.spire.doc.packages.sprvuca.spr┕┇—(Unknown Source)
   at com.spire.doc.packages.sprvuca.spr┨┈—(Unknown Source)
   at com.spire.doc.packages.sprvuca.spr┕┇—(Unknown Source)
   at com.spire.doc.packages.sprvuca.spr™┇—(Unknown Source)
   at com.spire.doc.packages.sprexca.spr⁆(Unknown Source)
   at com.spire.doc.packages.sprnzz.spr∮‡—(Unknown Source)
   at com.spire.doc.packages.sprnzz.spr㈬⃝”—(Unknown Source)
   at com.spire.doc.documents.Paragraph.appendHTML(Unknown Source)
   at io.dealhub.documents.generation.service.RichTextCreator.createRichText(RichTextCreator.java:19)


while executing next code:
Code: Select all
    public void createRichText(StructureDocumentTag sdt, String html) {
        if (StringUtils.isEmpty(html)) {
            return;
        }
        sdt.getSDTContent().addParagraph().appendHTML(html)
    }

wth html:
Code: Select all
<table border="1" cellpadding="5" cellspacing="5" style="width:500px">
   <tbody>
      <tr>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
      </tr>
      <tr>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
      </tr>
      <tr>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
      </tr>
      <tr>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
      </tr>
   </tbody>
</table>

<p>&nbsp;</p>

We use SpireDoc for Java 12.12.21. This code worked with version 12.6.2
Please help to resolve this issue.
Thanks, Andrei

andrei.chorin
 
Posts: 68
Joined: Sun Jan 08, 2023 2:36 pm

Tue Jan 14, 2025 2:36 am

Hello,

Thank you for your letter. I use the following code to test versions 12.6.2 and 12.12.21, there are no issues on my end.
Code: Select all
    String html="<table border=\"1\" cellpadding=\"5\" cellspacing=\"5\" style=\"width:500px\">\n" +
                "   <tbody>\n" +
                "      <tr>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "      </tr>\n" +
                "      <tr>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "      </tr>\n" +
                "      <tr>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "      </tr>\n" +
                "      <tr>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "      </tr>\n" +
                "   </tbody>\n" +
                "</table>\n" +
                "\n" +
                "<p>&nbsp;</p>";

        Document document = new Document();

        //Add a new section.
        Section section = document.addSection();

        //Add sdt
        StructureDocumentTag sdt = new StructureDocumentTag(document);
        section.getBody().getChildObjects().insert(0,sdt);
       
        //Add html
        sdt.getSDTContent().addParagraph().appendHTML(html);
   
        //Save the document
        String output = "out.docx";
        document.saveToFile(output, FileFormat.Docx);

Please confirm if there are any differences in your code. If so, please provide your complete code and input testing document, so that we can further verify the testing. You can provide it here or send them to [email protected].

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1510
Joined: Wed Apr 25, 2018 3:20 am

Tue Jan 14, 2025 8:44 am

Thaks for quick answer.
For us failing when we adding SDT to document after appending HTML (this worked in before):
Code: Select all
    String html="<table border=\"1\" cellpadding=\"5\" cellspacing=\"5\" style=\"width:500px\">\n" +
                "   <tbody>\n" +
                "      <tr>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "      </tr>\n" +
                "      <tr>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "      </tr>\n" +
                "      <tr>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "      </tr>\n" +
                "      <tr>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "         <td>&nbsp;</td>\n" +
                "      </tr>\n" +
                "   </tbody>\n" +
                "</table>\n" +
                "\n" +
                "<p>&nbsp;</p>";

        Document document = new Document();

        //Add a new section.
        Section section = document.addSection();

        //Create sdt
        StructureDocumentTag sdt = new StructureDocumentTag(document);

       
        //Add html
        sdt.getSDTContent().addParagraph().appendHTML(html);
      
   //Add sdt
   section.getBody().getChildObjects().insert(0,sdt);
   
        //Save the document
        String output = "out.docx";
        document.saveToFile(output, FileFormat.Docx);


Thankis,
Andrei

andrei.chorin
 
Posts: 68
Joined: Sun Jan 08, 2023 2:36 pm

Tue Jan 14, 2025 10:12 am

Hello,

Thank you for your feedback. Is your issue also occur when running my code? Please provide more information so that we can simulate your environment for testing.
1.Your system information (E.g. Win10, 64 bit) and region setting (E.g. China, Chinese).
2. Your JDK version.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1510
Joined: Wed Apr 25, 2018 3:20 am

Tue Jan 14, 2025 2:24 pm

When I change order (first add SDT to Document, then set content) import working without error.

Regards,
Andrei

andrei.chorin
 
Posts: 68
Joined: Sun Jan 08, 2023 2:36 pm

Wed Jan 15, 2025 3:29 am

Hello,

Thank you for your further feedback. Yes, I also noticed that the operation(first set Html content,then add SDT to Document) occurred the exception in the latest version. I have logged this issue into our bug system with SPIREDOC-11067. Our Dev team will further fix it, once it is resolved, we will update the hotfix version to you as soon as possible. Thank you for your understanding.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1510
Joined: Wed Apr 25, 2018 3:20 am

Tue Feb 25, 2025 9:34 am

Hello,

Thanks for your patience.
Our latest Spire.Doc for Java Version:13.2.1 included the fixes of SPIREDOC-11067. Welcome to test it.


Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1510
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Doc