Using code from the demos, I am creating the first row of a table, and later, I want to add more rows.
The created row is shown to the user in the editor, and acts as a header, and also as a template, the user can change text properties and widths of the colums.
Table creation uses the following code
Code
var tbl: TParagraph; // Create the table and after that modify the cells WPRichText1.BeginTable('NAME', 0, 0, 0); tbl := WPRichText1.TableAdd(4, 1, [wptblActivateBorders], nil, nil); WPRichText1.EndTable; // Set text of columns tbl.Rows[0].Cols[0].SetText('Product'); tbl.Rows[0].Cols[1].SetText('Price'); tbl.Rows[0].Cols[2].SetText('Amount'); tbl.Rows[0].Cols[3].SetText('Total');
Then, when the user wants to print the resulting document, I am adding rows with the following code
Code
var
par, row: TParagraph;
par := WPRichText1.FindTable('NAME');
if par = nil then ShowMessage('Table "NAME" was not found') else
begin
// Get the last row
row := par.Rows[par.RowCount - 1];
// Duplicate it
row := row.RowAppend;
// and add some text. The properties and formulas have been automatically duplicated!
if row <> nil then
begin
row.Cols[0].ASetCharStyle(false, WPSTY_BOLD);
row.Cols[0].SetText(IntToStr(row.RowNr));
row.Cols[2].SetText(IntToStr(Random(1000) + 1));
row.Cols[3].SetText(IntToStr(Random(3) + 1));
end;
end;
Alles anzeigen
The problem is that ASetCharStyle does not delete the bold flag from the new row, so how can I delete the bold flag from all the content of a table cell.