insertHTML border-collapse

Hello,

It seems the “border-collapse” style attribute doesn’t work in aspose.words’ documentbuilder.inserthtml.

The following html:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        
        <style type="text/css"></style>
    </head>
    <body>
        <table style="border-collapse:collapse;width:400px" border="1">
            <tr>
                <td>text</td>
                <td>text</td>
            </tr>
            <tr>
                <td>text</td>
                <td>text</td>
            </tr>
        </table>
    </body>
</html>

is converted to a table with border-spacing (cellspacing), while the border-collapse property is set to collapse.

can you confirm this issue? (for our own reference: #38392)

Paul Vrugt
Sr. Software Engineer
Infoland BV

Hi Paul,

Thanks for your inquiry. Unfortunately, HTML table styling is currently not supported by Aspose.Words. I have linked your request to the appropriate feature (i.e. WORDSNET-3163) in our issue tracking system. You will be notified via this forum thread once this feature is available. Please read list of table features supported on HTML import/export here:
https://docs.aspose.com/words/net/table-features-supported-on-html-import/
https://docs.aspose.com/words/net/table-features-supported-on-html-export/

Moreover, please read list of style features supported on HTML import/export.
https://docs.aspose.com/words/net/style-features-supported-on-html-import/
https://docs.aspose.com/words/net/style-features-supported-on-html-export/

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-3163) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(41)

It seems that this issue was not completely resolved?
Inserting the following table into an Aspose document:

<html>
<STYLE>
    body {
        font-size: 12pt;
        font-family: "Times New Roman";
    }

    td {
        font-size: 12pt;
        font-family: "Times New Roman";
    }
</STYLE>
<body>
    <TABLE width="600" border="1" bordercolor="#111111" cellpadding="2" style="border-collapse: collapse">
        <tr height="18">
            <td width="30" bgColor="#D3D3D3"><p align="center">Nr.</p></td>
            <td width="240" bgColor="#D3D3D3"><p align="left">Naam</p></td>
            <td width="70" bgColor="#D3D3D3"><p align="center">Postcode</p></td>
            <td width="110" bgColor="#D3D3D3"><p align="left">Woonplaats</p></td>
            <td width="100" bgColor="#D3D3D3"><p align="right">Prijs incl. btw*</p></td>
            <td width="50" bgColor="#D3D3D3"><p align="left">Verzendwijze</p></td>
        </tr>
        <tr height="18">
            <td width="30"><p align="center">1</p></td>
            <td width="240"><p align="left">Dynatherm bvba</p></td>
            <td width="70"><p align="center">8370</p></td>
            <td width="110"><p align="left">Blankenberge</p></td>
            <td width="100"><p align="right">&#8364;&#160;78.205,11</p></td>
            <td width="50"><p align="left">Afgegeven</p></td>
        </tr>
        <tr height="18">
            <td width="30"><p align="center">2</p></td>
            <td width="240"><p align="left">2 By 2 nv</p></td>
            <td width="70"><p align="center">2170</p></td>
            <td width="110"><p align="left">Merksem (Antwerpen)</p></td>
            <td width="100"><p align="right">______________</p></td>
            <td width="50"></td>
        </tr>
        <tr height="18">
            <td width="30"><p align="center">3</p></td>
            <td width="240"><p align="left">2B Concepts</p></td>
            <td width="70"><p align="center">9320</p></td>
            <td width="110"><p align="left">Wetteren</p></td>
            <td width="100"><p align="right">______________</p></td>
            <td width="50"></td>
        </tr>
    </TABLE>
</body>
</html>

Yields the attached result using Aspose 13.11.0.0
Do you have any idea why this is not working correctly?

Hi there,

Thanks for your inquiry.

I have tested the scenario and have managed to reproduce the same issue at my side. Unfortunately, the WORDSNET-3163 (Support CSS styles on table, tr, td and th nodes on import) does not solve the table’s style ‘border-collapse: collapse’ issue.

For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-9462. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Thank you for the quick response Tahir.

I have now tried to avoid the issue by manually correcting the tables afterwards (as I know I always want the tables with collapsed borders) by setting the CellSpacing to -1. Visually everything looks ok but when I check the table properties I find the attached value.

The CellSpacing is not disabled and it’s value has been set to -0.04cm. Trying to disable this checkbox Word will give me an exception that the value has to be between 0 and 5.6 cm. When I clear the value AND disable the checkbox the layout changes slightly to exactly what I want as a result.

Setting the value to 0 in Aspose OR in Word itself also gives me wrong results so I would like to be able to just disable the CellSpacing but apparently that setting is not available?

Hi there,

Thanks for your inquiry. Please set the value of table’s cell spacing/padding to 0.0 as shown in following code example. Hope this helps you. Please let us know if you have any more queries.

var doc = new Document(MyDir + "in.htm");
foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
    table.CellSpacing = 0.0;
    table.BottomPadding = 0.0;
    table.TopPadding = 0.0;
    table.RightPadding = 0.0;
    table.LeftPadding = 0.0;
    table.SetBorders(LineStyle.Hairline, .25, Color.Black);
}
doc.Save(MyDir + "Out.docx");

I have tried your solution and the result is not as expected (see image).

As you can see all horizintal lines have dissapeared and the vertical lines are still drawn twice right next to eachother.

Hi there,

Thanks for your inquiry. I have tested the scenario and have manged to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-9494. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

As a workaround, please use cellpadding and cellspacing properties of table tag as shown below in your htm. I have attached the input and output document with this post for your kind reference.

<TABLE width=“600” border=“1” bordercolor="#111111" cellpadding=“2” style=“border-collapse: collapse” cellpadding=“0” cellspacing=“0” >

Hi,

Your latest solution indeed provides me with the exact solution I need. When I open up Word and check the settings, the “allow space between cells” checkbox also is unchecked. Apparently it IS possible for Aspose to manipulate this checkbox so it would be nice to expose this feature to the developers :).

Thank you for the great support, I can continue developping our application for a future purchase now!

If the changes to the CSS parsing would be pushed into a release I can remove these extra conditions/parameters again.

Hi there,

Thanks for your inquiry.

Nickman1987:
Hi,
Apparently it IS possible for Aspose to manipulate this checkbox so it would be nice to expose this feature to the developers :).

I have logged this feature request as WORDSNET-9498 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-9462;WORDSNET-9494) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-9498) have been fixed in this Aspose.Words for .NET 18.11 update and this Aspose.Words for Java 18.11 update.