Free Support Forum -

Error thrown when tring to build a table with borders

Here's the error...

Exception 'The requested border is not available for this object.' occured in Aspose.Words for .NET For free technical support, please post this error and the file in the Aspose.Words Forums

I am trying to build a very wide table. There is a lot of data so I need borders...
builder.CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.Hairline;
builder.CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.Hairline;

Do I need body in my section? Right now I have..

doc -> section -> table

should it be?..

doc -> section -> body -> table


Thanks for your request. Try to use the following code to achieve your task.

builder.CellFormat.Borders[BorderType.Bottom].LineStyle = LineStyle.Hairline;

builder.CellFormat.Borders[BorderType.Top].LineStyle = LineStyle.Hairline;

builder.CellFormat.Borders[BorderType.Left].LineStyle = LineStyle.Hairline;

builder.CellFormat.Borders[BorderType.Right].LineStyle = LineStyle.Hairline;

I hope that it will help you.

Best regards.