Free Support Forum - aspose.com

How to show Table Borders

Is there any way to make table borders visible .

Actually i am creating the table and populating data in it using external data source in C#.

But when I open that word document i dont see any table borders.

I searched Aspose.Word documentation, but I found only IsVisible property which is read only.

Hi

Thanks for your inquiry. I think that you should set borders LineStyle. For example see the following code.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

//Set borders.

builder.CellFormat.Borders.LineStyle = LineStyle.Single;

builder.CellFormat.Borders.LineWidth = 1;

builder.CellFormat.Width = 100;

//Build table

for (int rowIndex = 0; rowIndex < 5; rowIndex++)

{

for (int columnIndex = 0; columnIndex < 5; columnIndex++)

{

builder.InsertCell();

builder.Write("Test");

}

builder.EndRow();

}

builder.EndTable();

//Save document

doc.Save(@"Test009\out.doc");

Hope this helps.

Best regards.