delete(aword, length(aword)-1, 2)
else}
//{$endif}
{ begin
delete(aword, length(aword), 1);
end;
end;
newline := aword;
flushline;
aword := '';
end;}
if not wordwrap then
begin
aword := '';
linefinished := true;
end;
end;
newline := newline + aword;
end;
关于自动折行所引起的页行数可变控制
需求:文本折行后,是已设格式的行高自动变化,行数不容易控制,预览效果不堪入目。
解决方法:不允许已设行高自动变化,根据detail行高取舍文本的行数。例:不折行的情况下打印5行的固定
格式,会因为折行而打不了5行,程序自动将行高增大,在套打的情况下,情况非常糟糕。所以强制固定行高,
如果折行超过了固定高度,则超出部分不打印。
源码:文件 qrctrls;主函数 printtocanvas;子函数canprint
找到下面着一行
tqrcustomband(parent).expandband(lineheight, afexpanded, hasexpanded);
该行是根据你的caption的行数来增加行数的,所以屏蔽掉
在主函数中找到下面这一行
controlbottom := atop + aheight +1;
修改为
controlbottom := atop + tqrcustomband(parent).size.length +1;
tqrcustomband(parent).size.length 是当前detail的行高
然后找到下面这个循环
while (fcurrentline <= fformattedlines.count - 1) and canprint do
if (fcurrentline <= fformattedlines.count - 1) and canprint then
begin
printline(fcurrentline);
inc(fcurrentline);
end;
修改为
while (fcurrentline <= fformattedlines.count - 1) and canprint do //taogou
if (fcurrentline <= fformattedlines.count - 1) and canprint then
begin
if y + lineheight < controlbottom then //taogou y为当前开始打印的位置,lineheight为字符行高
printline(fcurrentline); //controlbottom为detail的下限位置,仅当位置小于允许的位置才打印
inc(fcurrentline);
end;
fcurrentline:=fformattedlines.count; //不管打了几行,都将当前行表示为该caption已经打印完毕
需求:控制多余行数,例:页打印行数为5行,当前打印记录数为12,带格式不套打,
则在最后页只有2行数据,从第3行到页脚为一片空白。这里需要将最后一页上3行打印上无数据的空格式.
解决方法:循环n次detail行的打印方法,并屏蔽掉记录
源码:文件 quickrpt;主函数 tqrcontroller.execute
hasprintedlines:=0; //新增本函数局部变量 记录已经打印的行数
while moredata do
begin
inc(hasprintedlines); //增1
application.processmessages;
if parentreport.qrprinter.cancelled then
exit;
if parentreport.preparingdesigntime and (parentreport.fpagecount > 1) then exit;
inc(fdetailnumber);
printgroupheaders;
printbeforecontrollers;
parentreport.printband(fdetail);
printaftercontrollers;
if dsok then
begin
dataset.next;
moredata := not fdataset.eof;
if (fdataset.eof) then //add begin
begin
if fdetail<>nil then //将detail中的tqrdbtext and tqrlabel 全部不打
for j:=0 to fdetail.controlcount-1 do
begin
if fdetail.controls[j] is tqrdbtext then
tqrdbtext(fdetail.controls[j]).enabled:=false;