Keep CHPX of table when adding rows
Posted: Wed Feb 07, 2024 8:17 am
I'm adding rows to a TAXWTable and I want those rows to keep the same formatting (font, font size, color, etc.) as the first row.
I have found half of the solution
But this hard sets the font to Times New Roman and our clients want to be able to customize their docx templates with their desired fonts, sizes and colors and not have them changed when filling the table with data.
How do I retain the formatting of the table from the template?
Code: Select all
//ATable: TAXWTable, TableRow: TAXWTableRow
TableRow := ATable.Rows.Add;
TableRow.Assign(ATable[0], False); //Font of first cell of first row is 'Times New Roman' (Also tried AAssignText True)
TableRow.Cells[0].Paras.PlainText := 'Sample Text'; //Font of cell is 'Arial'
Code: Select all
chpx := TAXWCHPX.Create(nil);
chpx.FontName := 'Times New Roman';
TableRow.Cells[0].Paras.FormatAll(chpx);
How do I retain the formatting of the table from the template?