Hi all,
I want to create a table in Word doc in C#, which has “Repeat as header row at the top of each page”.
I am new to Aspose Word. Please provide code sample.
Thanks in advance
Hi all,
I want to create a table in Word doc in C#, which has “Repeat as header row at the top of each page”.
I am new to Aspose Word. Please provide code sample.
Thanks in advance
Hello
Thanks for your request. Please see the following code for example:
// Create document and DocumentBuilder
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create heading row that will be repeated on each page
builder.RowFormat.HeadingFormat = true;
builder.Bold = true;
for (int i = 0; i <5; i++)
{
builder.InsertCell();
builder.Write(string.Format("heading_{0}", i));
}
builder.EndRow();
builder.RowFormat.HeadingFormat = false;
builder.Bold = false;
// Generate body of table
for (int rowIdx = 0; rowIdx <100; rowIdx++)
{
for (int colIdx = 0; colIdx <5; colIdx++)
{
builder.InsertCell();
builder.Write(string.Format("value_of_{0}_{1}", rowIdx, colIdx));
}
builder.EndRow();
}
builder.EndTable();
// Save output document
doc.Save("out.doc");
Please set HeadingFormat = True if the row is repeated as a table heading on every page when the table spans more than one page.
I hope this could help you.
Best regards,
Thank you very much. It works!!