Hello,
I'm adding a single row to a table, then populating the table with the ImportDataTable() method. After setting up my columns I try to reset the Accredited heading column back to the desired color and alignment. When I do this both the first and second rows in the table are changed.
This is my code:
Section section3 = pdf.Sections.Add();
SetSectionMargins(section3);
section3.IsNewPage = true;
// Table for data
Aspose.Pdf.Table pdfTable = new Aspose.Pdf.Table();
pdfTable.Margin.Top = 10;
pdfTable.Alignment = AlignmentType.Center;
section3.Paragraphs.Add(pdfTable);
pdfTable.ColumnWidths = "70 80 90 70 50 50";
pdfTable.DefaultCellBorder = new BorderInfo((int)BorderSide.All, 0.1F);
//
// Add a header row to the table.
//
Row pdfRow = pdfTable.Rows.Add();
TextInfo headingTextInfo = new TextInfo();
headingTextInfo.FontSize = 13;
headingTextInfo.IsTrueTypeFontBold = true;
headingTextInfo.Color = new Aspose.Pdf.Color(255, 255, 255);
headingTextInfo.BackgroundColor = new Aspose.Pdf.Color(51, 51, 101);
pdfRow.Cells.Add("Test Name", headingTextInfo);
pdfRow.Cells.Add("Method", headingTextInfo);
pdfRow.Cells.Add("Description", headingTextInfo);
pdfRow.Cells.Add("Accredited", headingTextInfo);
pdfRow.Cells.Add("DL High", headingTextInfo);
pdfRow.Cells.Add("DL Low", headingTextInfo);
pdfTable.ImportDataTable(legendTable, false, 0, 0);
// Center data in the Accredited column
TextInfo colTextInfo = new TextInfo();
colTextInfo.Alignment = AlignmentType.Center;
pdfTable.SetColumnTextInfo(ACCREDITED_CELL, colTextInfo);
// Need to reset the Accredited column heading
pdfTable.Rows[0].Cells[ACCREDITED_CELL].DefaultCellTextInfo = headingTextInfo;
return pdf;