Hi pegaso,
Thank you for your interest in Syncfusion products.
Set the header text in PdfLightTableWe can able to set the header text in PdfLightTable by using table.Columns[index].ColumnName property.
Kindly refer the below code snippet which helps to set the header text in PdfLightTable.
//Create PDF document
PdfDocument doc = new PdfDocument();
//Create a font
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Create Pdf pen for drawing broder
PdfPen borderPen = new PdfPen(PdfBrushes.DarkBlue);
borderPen.Width = 0;
//Add a page.
PdfPage page = doc.Pages.Add();
//Use DataTable as source
PdfLightTable table = new PdfLightTable();
//Create datatable
DataTable dataTable = GetTable(30, 5);
//Set Data source
table.DataSource = dataTable;
//Set Column Headers
table.Columns[0].ColumnName = "Employee Name";
table.Columns[1].ColumnName = "Office Phone";
table.Columns[2].ColumnName = "Office Email";
PdfCellStyle headerStyle = new PdfCellStyle(font, PdfBrushes.White, PdfPens.DarkBlue);
brush = new PdfSolidBrush(Color.FromArgb(33, 67, 126));
headerStyle.BackgroundBrush = brush;
//Set header row style
table.Style.HeaderStyle = headerStyle;
//Show the header row
table.Style.ShowHeader = true;
//Repeate header in all the pages
table.Style.RepeatHeader = true;
//Set header data from column caption
table.Style.HeaderSource = PdfHeaderSource.ColumnCaptions;
//Set layout properties
PdfLayoutFormat format = new PdfLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
//Draw table
table.Draw(page, PointF.Empty, format);
//Save the document
doc.Save("Sample.pdf");
private DataTable GetTable(int rowCount, int colCount)
{
DataTable temp = new DataTable();
for (int i = 0; i < colCount; i++)
temp.Columns.Add("Column" + i.ToString());
for (int j = 0; j < rowCount; j++)
{
string[] value = new string[colCount];
for (int i = 0; i < colCount; i++)
value[i] = i.ToString() + "," + j.ToString();
temp.Rows.Add(value);
}
return temp;
}
}
Please do find the sample from the below specified location which demonstrates Set the Header text in PdfLightTable and let me know if this helps,
http://files.syncfusion.com/support/PDF.Windows/F89515/TableHeader.zipRegards,
Thiru