Function TParagraph.AppendNewRow(DontCopyStyle:Boolean; LastRow:TParagraph) : TParagraph
Unit: WPRTEDefs
Class: WPRTEDefs.TParagraph
Parameters
-
DontCopyStyle:Boolean LastRow:TParagraph
Returns
The type of the result value is TParagraph.
Description
Append an empty row paragraph to this table or after this paragraph if this paragraph is a row paragraph. You can useIn this example we create a table with 6 cells. In the second row the first two cells are merged.
var tab, row, cell : TParagraph;
begin
WPRichText1.Clear;
// Table
tab := WPRichText1.BodyText.AppendTable;
// Row #1
row := tab.AppendNewRow();
cell := row.AppendNewCell();
cell.ASet(WPAT_BorderFlags,15);
cell := cell.AppendNewCell();
cell.ASet(WPAT_BorderFlags,15);
cell := cell.AppendNewCell();
cell.ASet(WPAT_BorderFlags,15);
// Row #2
row := tab.AppendNewRow();
cell := row.AppendNewCell(false, 2); // 2 columns col span (Requires WPTools 9)
cell.ASet(WPAT_BorderFlags,15);
cell := cell.AppendNewCell(false, 1); // 1 column, but append after last spanned cell
cell.ASet(WPAT_BorderFlags,15);
WPRichText1.ReformatAll();
end;
Here we create header and footer rows.
var wp : TWPCustomRTFEdit;
table, row, cell : TParagraph;
c, r : Integer;
begin
wp:=WPRichText1;
table:=wp.ActiveText.AppendTable(nil, nil);
// Header
row:=table.AppendNewRow(false);
row.IncludeProp(paprIsHeader);
for c:=0 to 3 do
begin
cell:=row.AppendNewCell(false);
cell.SetText(Format('Header %d', [c]));
end;
// Data - 1000 rows
row:=nil;
for r:=1 to 1000 do
begin
row:=table.AppendNewRow(false);
for c:=0 to 3 do
begin
cell:=row.AppendNewCell(false);
cell.SetText(Format('%d Data A %d', [r, c]));
if c<3 then
cell.IncludeProp(paprRowMergeFirst);
if (r and 1)=1 then cell.ASetColor(WPAT_BGColor, clGray);
end;
row:=table.AppendNewRow(false);
for c:=0 to 3 do
begin
cell:=row.AppendNewCell(false);
if c<3 then
cell.IncludeProp(paprRowMerge)
else cell.SetText(Format('Data B %d', [c]));
if (r and 1)=1 then cell.ASetColor(WPAT_BGColor, clGray);
end;
end;
// Footer at the very end
row:=table.AppendNewRow(false);
for c:=0 to 3 do
begin
cell:=row.AppendNewCell(false);
cell.SetText(Format('Footer %d', [c]));
end;
wp.ReformatAll(false, true);
end;