This code prints a multiplication table with these custom print settings:
The informative rows above the table won''t be printed.
The first row and column of the table will be printed on every page.
The first row and column are fixed for scrolling.
Open a print preview to see how the table is printed.
uses
{...}, OExport, OExport_Vcl, OExport_VclForms;
procedure TForm1.BtnTestClick(Sender: TObject);
var
xExport: TOExport;
I, L: Integer;
begin
xExport := TOExport.Create;
try
with xExport.AddWorkSheet('Table Header') do begin
Header.Center.Text := 'Multiplication table';
AddRow.AddCellString('Multiplication table').SetFontSize(20);
AddRow.AddCellString('Example: Print big table').SetFontSizeAdd(2);
AddRow.AddCellString('1) These informative rows above the table won''t be printed.');
AddRow.AddCellString('2) The first row and column of the table will be printed on every page.');
AddRow.AddCellString('3) The first row and column are fixed for scrolling.');
AddRow;
AddRow;
//SET PRINT RANGE [1]
PageSettings.PrintRange.Col := 0;
PageSettings.PrintRange.Row := Rows.Count;
//SET REPEAT COLUMN/ROW (THAT WILL BE PRINTED ON EVERY PAGE)
PageSettings.ColsToRepeat.LeftCol := 0;
PageSettings.ColsToRepeat.RightCol := 0;
PageSettings.RowsToRepeat.TopRow := Rows.Count;
PageSettings.RowsToRepeat.BottomRow := Rows.Count;
//SET WINDOWS SPLIT / FIXED CELL (FOR DOCUMENT SCROLLING)
WindowSettings.Split.Row := Rows.Count+1;
WindowSettings.Split.Col := 1;
for I := 0 to 100 do
with AddRow do begin
for L := 0 to 30 do begin
if I = 0 then begin
if L = 0 then
AddCellString('A * B').SetFontStyle([fsBold]).
SetBGColor(clYellow).SetAlignment(taCenter)
else
AddCellString('A = '+IntToStr(L)).SetFontStyle([fsBold]).
SetBGColor(clYellow).SetAlignment(taCenter);
end else if L = 0 then begin
AddCellString('B = '+IntToStr(I)).SetFontStyle([fsBold]).
SetBGColor(clYellow).SetAlignment(taCenter);
end else begin
AddCellFormulaNumber(IntToStr(L)+'*'+IntToStr(I), 0);
end;
end;
end;
//SET PRINT RANGE [2]
PageSettings.PrintRange.RightCol := Rows[Rows.Count-1].Cells.Count-1;
PageSettings.PrintRange.BottomRow := Rows.Count-1;
end;
xExport.SaveToFileWithDialog;
finally
xExport.Free;
end;
end;