fastreport打印代码及SQL合并字段的语句
procedure Tform1.Button5Click(Sender: TObject);
var
p:pointer;
FrfStr:string;
begin
inherited;
Screen.Cursor:=MYCURSORWAITHAND;
with cdsPrint do
begin
Active:=false;
/
/这个SQL⽤于将remark中的记录合并到⼀起!
CommandText:='select a.ITEM_ID, a.ITEM_NAME,count(a.Coll_ID) as num,ltrim(max(sys_connect_by_ark, '';'')), '';'') remark '
+' from (select /*+index(b,TAB_ORDER_I)*/ b.ITEM_ID,b.Coll_ID,b.ITEM_ark,row_number() over(partition by b.ITEM_ID order by b.ITEM_ID)'
+' ITEM_ID1,row_number() over(order by b.ITEM_ID) + dense_rank() over(order by b.ITEM_ID) ITEM_ID2 '
+' from TAB_ORDER b where b.Coll_ID ='''+DBComboBoxEh1.Text+''''
+' ) a'
+' start with ITEM_ID1 = 1 connect by prior ITEM_ID2 = ITEM_ID2-1 group by a.ITEM_ID,'
+' a.ITEM_NAME order by a.ITEM_ID ';
Active:=true ;
end;
cds_Print.DisableControls;
p:=cdsPrint.GetBookmark;
FrfStr:='report1l.frf';
try
if cdsPrint.Active and (cdsPrint.RecordCount<>0) then
begin
frReport1.LoadFromFile(ExtractFilePath(ParamStr(0))+'Report/'+FrfStr);
PrintSet;
frReport1.ShowReport;
end
else
begin
Screen.Cursor:=crDefault;
Application.MessageBox(pchar(STR_MESSAGEBOX_HEADER+'没有数据可打印'),pchar(self.Caption),MB_OK or MB_ICONEXCLAMATION);
end;
finally
cdsPrint.GotoBookmark(p);
cdsPrint.EnableControls;
report是什么意思Screen.Cursor:=crDefault;
end;
end;
//设置⼀些打印项
procedure Tform1.PrintSet;
var
str:string;
temp:TfrView;
begin
temp:=frReport1.FindObject('Print_Time');
if temp<>nil then temp.Memo.Text:=trim(temp.Memo.Text)+DateTimeToStr(date);
temp:=frReport1.FindObject('PrintPage');
if temp<>nil then temp.Memo.Text:='第[PAGE#]页/共[TOTALPAGES]页';
end;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论