We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to create table in Aspose.Word

Hi,

Can you provide a simple code, demonstration a table with border in Aspose.Word.

Thanks,

Siraj

Hi

Thanks for your inquiry. The easiest way to create table is using Documentbuilder. Please see the following link for more information.

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/inserting-a-table.html

Also see the following code example:

//Create new Document and DocumentBuilder

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

//Set borders

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

builder.CellFormat.Borders.Color = Color.Red;

//Generate simple table

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

{

for (int j = 0; j < 3; j++)

{

//Insert cell

builder.InsertCell();

builder.Write("test");

}

builder.EndRow();

}

builder.EndTable();

//Save document

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

Hope this helps.

Best regards.