How to inspect table borders

Hi Aspose,

In my code I do a lot of table generation from source text, and wanted to add in some integration tests to make sure my code is setting up table border properties correctly. I notice that while setting the table borders works fine, there’s no obvious way to inspect what the vaules were actually set to from within the code. For example, if I do:

table.SetBorder(BorderType.Horizontal, LineStyle.Wave, 2, Color.Blue, false);

It sets the insideh border perfectly, and the document renders as I would expect, but I can’t seem to find a way to check the values that it has been set to using Aspose code. I’ve tried:

var insideh = (table.Style as TableStyle).Borders.Horizontal;
Assert.AreEqual(Color.Blue.ToArgb(), insideh.Color);

but the assert fails (I’m guessing this is due to the table style border being different from the actual table border). Is there a way to access the actual table border values from inside Aspose code?

Thanks,
Tomek

@acturisaspose Table.SetBorder actually sets the table border on row level. So, you can use RowFormat.Borders property to get the value set using Table.SetBorder method. internally code looks like this:

for (Row row = FirstRow; row != null; row = row.NextRow)
{
    // Now set the table border (we do this on the row level).
    Border border = row.RowFormat.Borders[borderType];
    border.LineStyle = lineStyle;
    border.LineWidth = lineWidth;
    border.Color = color;
}

worked like a charm, thanks!

1 Like