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.

Thu Nov 19, 2015 6:59 pm

Hi,

I'm evaluating Spire.Doc in order to use the library at my project. However I've hit a problem. I have HTML input file with following table:

Code: Select all
   <table border="0" >
       <tr><th colspan="18">Report</th></tr>
       <tr><th>22.10.2013</th><th>10:55:33</th><th>R1</th><th></th><th>A</th></tr>
       <tr><td>21.10.2013</td><td>10:44:28</td><td>R2</td><td></td><td>B</td></tr>
   </table>


When appending the table to document using Paragraph.AppendHTML() OR when loading the file using Document.LoadFromFile() and Document.LoadHTML() the operation fails with exception ArgumentOutOfRangeException in module mscorlib. It turns out to be caused by colspan="18". When the value is 2 the HTML document is processed correctly. When it's 3 or 4 I get stack overflow exception. When it's 18 I get ArgumentOutOfRangeException.

Can you help?

Thank you,


Petr

petrvo
 
Posts: 2
Joined: Thu Nov 19, 2015 10:17 am

Fri Nov 20, 2015 6:00 am

Hi Petr,

Thanks for your inquiry.
In your html code, the maximum number of the cells in the row is 5, so colspan value can be 1 or 2 or 3 or 4 or 5.
I tested 3 or 4 with Spire.Doc Pack(hot fix) Version:5.5.141, all were fine. Please try it.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri Nov 20, 2015 11:48 am

Hi Amy,

Thanks for your answer, it's very appreciated. I installed the hotfix you recommended. But I still see two issues:

1. According to HTML specification colspan attribute has numeric value, I see no limit to the value. I tried to open the file with colspan="18" in Microsoft Edge, Internet Explorer, Firefox, Microsoft Word and LibreOffice Writer. All these products interpret it with no problem. It seems that the first row of the table then gets 18 columns.

2. Even if colspan="5" I get stack overflow exception when combined with other attributes, but it is more difficult to describe. Please check the following example:

Code: Select all
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title></title>
</head>
<body>
    <table border="0" cellpadding="1">
        <tr>
            <th colspan="5">Report</th>
        </tr>
        <tr>
            <th>1</th>
            <th>2</th>
            <th>3</th>
            <th>aaaaaaaaaaaaaaa</th>
            <th>aaaaaaa. AA</th>
        </tr>
        <tr>
            <td>21.10.2013</td>
            <td>10:44:28</td>
            <td>R2</td>
            <td></td>
            <td>B</td>
        </tr>
    </table>
    <br>
</body>
</html>


This fails on stack overflow, with stack trace full of "Spire.Doc.dll!sprᤞ.ᜄ() + 0xb0 bytes" records. The problem seems to be somehow triggered by a combination of attributes cellpadding AND colspan AND the values in the table.

petrvo
 
Posts: 2
Joined: Thu Nov 19, 2015 10:17 am

Mon Nov 23, 2015 7:35 am

Hi,

Thanks for your feedback.
1. The browsers do the compatibility processing for the value. Our product only deals with the real value.
2. Please ensure Spire.Doc.dll, Spire.Pdf.dll and Spire.license.dll both are added into your project. I tested your html code with Spire.Doc 5.5.141 for .NET4.0 dlls to generate .doc file, .docx file and .html file, all result files were fine.
Test code as below:
Code: Select all
    Document document = new Document();;
            Section section = document.AddSection();
            Paragraph p = section.AddParagraph();
            string htmlcode = File.ReadAllText("..\\..\\htmlcode.txt");   
            p.AppendHTML(htmlcode);
            document.SaveToFile("6302.doc", FileFormat.Doc);
            document.SaveToFile("6302.docx", FileFormat.Docx);
            document.SaveToFile("6302.html", FileFormat.Html);

If the issue still exists, please share your code here to help us do an investigation.
Thank you.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Wed Mar 02, 2016 8:48 am

Hi,

I am evaluating this software for one of our projects. I tried converting a document with a table that has cell background colors but the html that was generated was not able to preserve those colors. I converted the doc to html and save it in a database.

Thanks

regards,
Clarence

clarkMe
 
Posts: 2
Joined: Wed Mar 02, 2016 4:18 am

Wed Mar 02, 2016 9:03 am

Hi Clarence,

Thanks for you posting and using our component.
Please try our latest version, Spire.Doc Pack(hot fix) Version:5.6.34 and set doc.HtmlExportOptions.CssStyleSheetType = CssStyleSheetType.Internal;.
If the issue still exists after trying above, please share your word document.
Thank you.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc