fastreport自带的例子就是打印StringGird, 主要就是一个GetValue方法的实现. 我拷贝了一段.
先要设置用户数据集的RangeEnd := reCount;
打印时设置RowDataSet.RangeEndCount := Grid.RowCount - 1;
//打印的行数.
procedure TFormSGVTasksMan.frReport1GetValue(const ParName: String;
var ParValue: Variant);
var
i : integer;
begin
for i := 0 to 10do
//列数,fastreport中memo标号从Cell0到Cell10
if ParName = 'Cell' + intToStr(i) then
begin
try
if (sPrintTypeStr = '自检') or (sPrintTypeStr = '送检') then
begin
if i = 0 then
//打印的记录序号,不是全部打印时,序号不能使用GridVTaskPlan的序号,否则中间会有不连续.
ParValue := intTostr(RowDataSet.RecNo + 1)
else
ParValue := GridVTaskMan.Cells[i, strToInt(sPrintRowNoList[RowDataSet.RecNo])];
end
else
ParValue := GridVTaskMan.Cells[i, RowDataSet.RecNo + 1];
break;
except
ParValue := '';
break;
end;
//ParValue := GridVTaskMan.Cells[i, RowDataSet.RecNo + 1];
//break;
end;
{if ParName = 'Pages' then
begin
ParValue := PagesTitle;
end;
}
if ParName = 'Title' then
begin
ParValue := TableTitle;
end;
if ParName = 'TitleAddin' then
begin
ParValue := TableTitleAddin;
end;
end;