Hello,
Thanks for your post.
I tested the below code with the latest
Spire.Office Platinum(Hotfix) Version:5.7.3 but found that header row was repeated when there was a page break. Attached is my output file.
- Code: Select all
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();
PdfGrid newGrid = new PdfGrid();
newGrid.Columns.Add(3);
float width = page.Canvas.ClientSize.Width - (newGrid.Columns.Count + 1);
for (int j = 0; j < newGrid.Columns.Count; j++)
{
newGrid.Columns[j].Width = width * 0.20f;
}
newGrid.AllowCrossPages = true;
//Add header row
PdfGridRow headerRow = newGrid.Headers.Add(1)[0];
float totalWidth = page.Canvas.ClientSize.Width;
for (int c = 0; c < 3; c++)
{
headerRow.Cells[c].Value = "Test";
newGrid.Columns[c].Format.Alignment = PdfTextAlignment.Center;
}
//Repear header
newGrid.RepeatHeader = true;
for (int c = 0; c < 100; c++)
{
PdfGridRow row = newGrid.Rows.Add();
row.Height = 20.0f;
row.Style.Font = new PdfTrueTypeFont(new Font("Arial", 12f, FontStyle.Bold), true);
row.Cells[0].Value = "Column 1";
row.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row.Cells[1].Value = "Column 2";
row.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row.Cells[2].Value = "Column 3";
row.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
}
newGrid.Draw(page, new PointF(0, 50));
doc.SaveToFile("result.pdf");
If you are using an older version, please try again with the latest version. Or if your code is different from mine, please provide your complete code for further investigation.
Sincerely,
Rachel
E-iceblue support team
Login to view the files attached to this post.