Display StringGrid in report
I am really struggling with diplaying a StringGrid in a report. I have copied the code from the sample Delphi application and changed it slightly to suit my application as follows.
procedure TfrmViewFormulation.rptFormulationBeforePrint(c: TfrxReportComponent);
var
Cross: TfrxCrossView;
i, j: Integer;
begin
if c is TfrxCrossView then
begin
Cross := TfrxCrossView©;
for i := 1 to 6 do
for j := 1 to 6 do
Cross.AddValue(, [j], [FormulaGrid.Cells[i, j]]);
end;
end;
When I preview the report the data from the StringGrid does not appear. If I add a breakpoint anywhere in the loop
begin
Cross := TfrxCrossView©;
for i := 1 to 6 do
for j := 1 to 6 do
Cross.AddValue(, [j], [FormulaGrid.Cells[i, j]]);
end;
it appears that this loop is never executed. If I put the breakpoint at "if c is TfrxCrossView then" then the execution stops at that point.
What have I missed?
procedure TfrmViewFormulation.rptFormulationBeforePrint(c: TfrxReportComponent);
var
Cross: TfrxCrossView;
i, j: Integer;
begin
if c is TfrxCrossView then
begin
Cross := TfrxCrossView©;
for i := 1 to 6 do
for j := 1 to 6 do
Cross.AddValue(, [j], [FormulaGrid.Cells[i, j]]);
end;
end;
When I preview the report the data from the StringGrid does not appear. If I add a breakpoint anywhere in the loop
begin
Cross := TfrxCrossView©;
for i := 1 to 6 do
for j := 1 to 6 do
Cross.AddValue(, [j], [FormulaGrid.Cells[i, j]]);
end;
it appears that this loop is never executed. If I put the breakpoint at "if c is TfrxCrossView then" then the execution stops at that point.
What have I missed?
Comments
My next question is how to change the width of the columns in the crosstab. There is a section in the manual that describes OnCalcWidth but I'm not sure how to add it to my code. I would also like to change the alignment of the cells depending on the column (ie columns 1 - 2 left align, columns 3 - 6 right align).
Mick