Repeating table header

I am trying to get a table that may break over several pages to have table header at the top of each page. I searched through this forum and found samples for doing that. But it just doesn’t work in my sample. Here is my code:

builder.StartTable();
builder.RowFormat.HeadingFormat = true;
builder.RowFormat.Borders.LineStyle = LineStyle.Single;
builder.InsertCell();
builder.Write("header");
builder.EndRow();
builder.RowFormat.HeadingFormat = false;

for (int i = 0; i < 100; i++)
{
    builder.InsertCell();
    builder.Write(i.ToString());
    builder.EndRow();
}
builder.EndTable();

What am I doing wrong?? Please give me some ideas!

Thanks!

Hi
Thanks for your inquiry. Your code works fine on my side. Please try using the latest version of Aspose.Words.
https://releases.aspose.com/words/net
Also you can try using the following code:

builder.StartTable();
builder.RowFormat.HeadingFormat = true;
builder.RowFormat.Borders.LineStyle = LineStyle.Single;
builder.InsertCell();
builder.Write("header");
builder.EndRow();
for (int i = 0; i < 100; i++)
{
    builder.InsertCell();
    builder.RowFormat.HeadingFormat = false;
    builder.Write(i.ToString());
    builder.EndRow();
}
builder.EndTable();

Hope this helps.
Best regards.

Ok, i’ll try to download the latest version of words.

I have tried exactly your code…it just doesn’t work…i have downloaded the latest version of aspose.words (5.3)…

any ideas?

tnx

Hi
Thanks for your inquiry. Could you please attach your output document?
Best regards.

Tnx for your answer!

When i save the document to the disc (docx format) and open it with ms word, then it works!!

But I need the same result in the editor…in the editor the header isn’t repeated.

Is it possible to get the same result in the editor?

Btw. here is the part of code:

…
docSave(@"D:\testHeading.docx");

MemoryStream ms = new MemoryStream();
doc.Save(ms, SaveFormat.Docx);

e.SetDocument(ms);
…

This gets two different results. The file testHeading.docx is ok, but the document in the editor isn’t.

Please help me to solve this.

tnx.

Hi
Thanks for your inquiry. Do you use Aspose.Editor? If so you should ask this question in the corresponding forum.
https://forum.aspose.com/c/words/8
Best regards,

Yes, I am using aspose editor.

Ok, I will ask there…tnx