I need a consistent way of getting table borders

Borders.zip (37.9 KB)
as you can see from my project, I have 2 test dot files.
in 1st, there are no borders at all, yet Aspose is reporting that the firstrow.rowformat.borders are all set.

in the second, there ARE borders, yet Aspose is reporting that 3 of the 4 borders are NOT set.

I need to work how to get the outline of the table, consistently.

@conniem,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-16841. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@conniem,

Further to my last post, we have logged a feature request as WORDSNET-16842 to get the border at table level. We will inform you via this forum thread once there is any update available on this feature. We apologize for your inconvenience.

@conniem,

It is to update you that we have closed the issue (WORDSNET-16842) with “Won’t Fix” resolution.

Please note that MS Word takes basic row level formatting for entire table from the first row. So all that you need is to get formatting of the first table row. Unfortunately, in your case, RowFormat.Borders returns incorrect value. We will inform you via this forum thread once there is any update available on WORDSNET-16841.

so, is there going to be a fix to the rowFormat.Borders issue NOT returning the correct value?

@conniem,

Yes, we are investigating this issue and will fix it. We will inform you via this forum thread once this issue is resolved. Thanks for your patience.

@conniem,

Thanks for your patience. You are facing the expected behavior of Aspose.Words. In your document, there are two tables - one in the header and one in the document.

You are getting table through Document.GetChild() method. This method gets all the tables of the document including the table in the header. If you want to use this method you have to use the index of the second table that is 1.

The better way to find a table in the document body is the access to Document.FirstSection.Body.Tables collection. Please check the following code example.

Document  AsposeDocument = new Document(MyDir + "test2.dot");
Console.WriteLine("Test 2 - table has all borders");
testborder(AsposeDocument);

static void testborder(Document AsposeDocument)
{

    Aspose.Words.Tables.Table m_Table = AsposeDocument.FirstSection.Body.Tables[0];
    Border bLeft;
    Border bRight;
    Border bTop;
    Border bBottom;
    Aspose.Words.BorderCollection Borders = m_Table.FirstRow.RowFormat.Borders;
    Console.WriteLine(Borders[BorderType.Top].LineStyle);
    Console.WriteLine(Borders[BorderType.Left].LineStyle);
    Console.WriteLine(Borders[BorderType.Right].LineStyle);
    Console.WriteLine(Borders[BorderType.Bottom].LineStyle);

    Borders = m_Table.FirstRow.FirstCell.CellFormat.Borders;
    bLeft = Borders[BorderType.Left];
    bRight = Borders[BorderType.Right];
    bTop = Borders[BorderType.Top];
    bBottom = Borders[BorderType.Bottom];
    Console.WriteLine(Borders[BorderType.Top].LineStyle);
    Console.WriteLine(Borders[BorderType.Left].LineStyle);
    Console.WriteLine(Borders[BorderType.Right].LineStyle);
    Console.WriteLine(Borders[BorderType.Bottom].LineStyle);
    Console.ReadLine();

}

okay, fixed that, please use this template.
the first table has no borders, but it keeps coming back that it does - even though they don’t show in word
test.zip (6.6 KB)

@conniem,

Thanks for your inquiry. Please open your template document in MS Word and save it to DOCX. Unzip the DOCX file and check the document.xml. You will see that table has border “single”. Please check the attached image for detail. Single border.png (18.9 KB). It seems that it is bug of MS Word as border is not visible when DOCX is opened in MS Word.