关于f1book控件的使用问题,关于数据库与f1book之间的数据交换!(100分)

  • 主题发起人 主题发起人 gophie
  • 开始时间 开始时间
G

gophie

Unregistered / Unconfirmed
GUEST, unregistred user!
本人需要做一个从数据库提取数据,并用excel格式打印的东东
但对f1book控件不熟悉。
问:提取数据如何放入不同的sheet.
数据保存在哪儿?(临时保存!)
打印预揽如何实现,曾见人提过输出用excel格式打印,如何实现?
可不可以象quickreport那样所见即所得?
为何对f1book的事件,方法。在delphi中的help中找不到?
我用delphi5,oracle8,
覆源代码请寄望gophie@263.net
 
formula one 有自己的help,我知道了!
 
f1book的打印预览有问题,可以输出为excel格式,在excel中预览。
 
如何调用excel打印玉兰!
 
呜呜
我当年什么都不懂,问出那么没有品位的话
但给天星100分又不心甘!
谁要分?报名,不需回答问题!
 
为什么要用 F1book,你听说过 EasyGrid 吗?
 
说来听听!BaKuBaKu
 
再问,如何用sort命令??
回答者有分的!
举个例子就行了!
 
BaKuBaKu:
哪儿有你说的 EasyGrid?可以妹我一份么?
上YAHOO查也没查到。
我想找这方面的东东,实在是找不到 :-(
pywhm@sina.com,谢谢!
 
procedure Treportfrm.shjyqxtz1;
var
i,J,dwbh,row,colmn,a:integer;
filetype:smallint;
month,year,day:word;
begin
with datamodule1.REPORTQRY1 do
begin
close;
sql.Clear;
sql.Add('truncate table report');
execsql;
close;
sql.Clear;
sql.add('insert into report select dwbh,bh,fcj from clmx where dwbh is not null ');
sql.add(' union all select dwbh,bh,fcj from clmxyk where dwbh is not null');
execsql;
close;
end;
decodedate(now,year,month,day);
filetype:=F1FileExcel5;
f1book1.read(ExtractFileDir(paramstr(0))+'/f1book1.xls',filetype);
REPORTFRM.Refresh;
//表1
row:=1;DWBH:=-1;
f1book1.sheet:=1;
with DATAMODULE1.REPORTQRY1 do
begin
CLOSE;
SQL.CLEAR;
SQL.ADD('select dwbh,bh,sum(fcj) from report where dwbh is not null group by dwbh,bh order by dwbh,bh ' );
OPEN;
FIRST;
dwbh:=fieldbyname('dwbh').asinteger;
while not eof do
begin
IF DWBH<>fieldbyname('dwbh').asinteger THEN
BEGIN
ROW:=ROW+1;
DWBH:=fieldbyname('dwbh').asinteger;
END;
colmn:=fieldbyname('bh').asinteger;
IF COLMN>19 THEN
begin
next;
CONTINUE;
end;
f1book1.textrc[row+4,1]:=fields[0].asSTRING;
f1book1.numberrc[row+4,colmn+2]:=fields[2].asfloat;
next;
end;
end;
a:=row+4;
//
ROW:=1;
DWBH:=-1;
with DATAMODULE1.REPORTQRy2 do
begin
CLOSE;
SQL.CLEAR;
SQL.ADD('SELECT DWBH,SUM(FCJ) FROM report WHERE DWBH IS NOT NULL GROUP BY DWBH ORDER BY DWBH');
OPEN;
FIRST;
dwbh:=fieldbyname('dwbh').asinteger;
while not eof do
begin
IF DWBH<>fieldbyname('dwbh').asinteger THEN
BEGIN
ROW:=ROW+1;
DWBH:=fieldbyname('dwbh').asinteger;
END;
if f1book1.TextRC[row+4,1]='' then
f1book1.textrc[row+4,1]:=fields[0].asSTRING;
f1book1.numberrc[row+4,2]:=fields[1].asfloat;
next;
end;
F1BOOK1.FormulaRC[4,2]:='SUM(B4:B80)';
f1book1.TextRC[1,1]:='1--'+inttostr(month)+'月份生产(经营)耗用物资及去向台帐';
f1book1.TextRC[2,2]:=datetostr(now);
end;
//OK }
//table 2
f1book1.Sheet:=2;
row:=1;DWBH:=-1;
with DATAMODULE1.REPORTqry1 do
begin
FIRST;
dwbh:=fieldbyname('dwbh').asinteger;
while not eof do
begin
IF DWBH<>fieldbyname('dwbh').asinteger THEN
BEGIN
ROW:=ROW+1;
DWBH:=fieldbyname('dwbh').asinteger;
END;
colmn:=fieldbyname('bh').asinteger;
IF (COLMN<=19) or (colmn>=40) THEN
begin
next;
CONTINUE;
end;
f1book1.textrc[row+4,1]:=fields[0].asSTRING;
f1book1.numberrc[row+4,colmn-18]:=fields[2].asfloat;
next;
end;
end;
//
ROW:=1;dwbh:=-1;
with DATAMODULE1.REPORTqry2 do
begin
FIRST;
dwbh:=fieldbyname('dwbh').asinteger;
while not eof do
begin
IF DWBH<>fieldbyname('dwbh').asinteger THEN
BEGIN
ROW:=ROW+1;
DWBH:=fieldbyname('dwbh').asinteger;
END;
if f1book1.TextRC[row+4,1]='' then
f1book1.textrc[row+4,1]:=fields[0].asSTRING;
next;
end;
f1book1.TextRC[1,1]:='1--'+inttostr(month)+'月份生产(经营)耗用物资及去向台帐(续一)';
f1book1.TextRC[2,2]:=datetostr(now);
end;
//
//table 3
f1book1.Sheet:=3;
row:=1;DWBH:=-1;
with DATAMODULE1.REPORTqry1 do
begin
FIRST;
dwbh:=fieldbyname('dwbh').asinteger;
while not eof do
begin
IF DWBH<>fieldbyname('dwbh').asinteger THEN
BEGIN
ROW:=ROW+1;
DWBH:=fieldbyname('dwbh').asinteger;
END;
colmn:=fieldbyname('bh').asinteger;
IF (COLMN<40) THEN
begin
next;
CONTINUE;
end;
f1book1.textrc[row+4,1]:=fields[0].asSTRING;
if colmn=99 then
f1book1.numberrc[row+4,21]:=fields[2].asfloat
else
f1book1.numberrc[row+4,colmn-38]:=fields[2].asfloat;
next;
end;
CLOSE;
end;
//
ROW:=1;dwbh:=-1;
with DATAMODULE1.REPORTqry2 do
begin
FIRST;
dwbh:=fieldbyname('dwbh').asinteger;
while not eof do
begin
IF DWBH<>fieldbyname('dwbh').asinteger THEN
BEGIN
ROW:=ROW+1;
DWBH:=fieldbyname('dwbh').asinteger;
END;
if f1book1.TextRC[row+4,1]='' then
f1book1.textrc[row+4,1]:=fields[0].asSTRING;
next;
end;
CLOSE;
END;
f1book1.TextRC[1,1]:='1--'+inttostr(month)+'月份生产(经营)耗用物资及去向台帐(续二)';
f1book1.TextRC[2,2]:=datetostr(now);
with DATAMODULE1.REPORTqry1 do
begin
CLOSE;
SQL.CLEAR;
SQL.ADD('select bh,sum(fcj) from report where dwbh is not null group by bh order by bh');
OPEN;
first;
while not eof do
begin
colmn:=strtoint(fields[0].asstring);
if colmn<=19 then
begin
f1book1.sheet:=1;
f1book1.numberRC[4,colmn+2]:=fields[1].asfloat;
end;
if (colmn>19) and (colmn<=39) then
begin
f1book1.sheet:=2;
f1book1.numberRC[4,colmn-18]:=fields[1].asfloat;
end;
if colmn>39 then
begin
f1book1.sheet:=3;
if colmn<>99 then
f1book1.numberRC[4,colmn-38]:=fields[1].asfloat
else
f1book1.numberRC[4,21]:=fields[1].asfloat;
end;
next;
end;
end;
WITH DATAMODULE1.REPORTQRY1 DO
BEGIN
CLOSE;
SQL.CLEAR;
SQL.ADD('SELECT * FROM YLDWMX');
OPEN;
END;
FOR I:=1 TO 3 DO
BEGIN
F1BOOK1.SHEET:=I;
f1book1.SetRowHeight(4,80,365,true);
FOR J:=5 TO 80 DO
IF F1BOOK1.TEXTRC[J,1]<>'' THEN
IF DATAMODULE1.REPORTQRY1.LOCATE('DWBH',F1BOOK1.TEXTRC[J,1],[]) THEN
F1BOOK1.TEXTRC[J,1]:=DATAMODULE1.REPORTQRY1.FIELDS[0].ASSTRING;
END;
f1book1.sheet:=1;
filetype:= F1FileExcel5;
f1book1.write(ExtractFileDir(paramstr(0))+'/SHHH.xls',filetype);
MsExcel:= CreateOleObject('Excel.Application');
WBook:=MsExcel.Application;
WBook.Visible:= True;
wbook.workbooks.Open(ExtractFileDir(paramstr(0))+'/SHHH.xls');
WSheet:=WBook.ActiveSheet;
REPORTFRM.Close;
wbook.Sheets['表1'].Select;
setgridline(3,A,'U');
WSheet.pagesetup.LeftMargin:=msexcel.InchesToPoints(0.196850393700787);
WSheet.pagesetup.RightMargin:=msexcel.InchesToPoints(0.196850393700787);
wbook.Sheets['表2'].Select;
setgridline(3,A,'U');
WSheet.pagesetup.LeftMargin:=msexcel.InchesToPoints(0.196850393700787);
WSheet.pagesetup.RightMargin:=msexcel.InchesToPoints(0.196850393700787);
wbook.Sheets['表3'].Select;
setgridline(3,A,'U');
WSheet.pagesetup.LeftMargin:=msexcel.InchesToPoints(0.196850393700787);
WSheet.pagesetup.RightMargin:=msexcel.InchesToPoints(0.196850393700787);
wbook.Sheets['表1'].Select;
end;
procedure Treportfrm.setgridline(startline, endline: integer;
endclomn: string);
begin
wsheet:=wbook.activesheet;
WSHEEt.PageSetup.PrintGridlines:=False;
WSHEEt.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlDiagonalDown].LineStyle:= xlNone;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlDiagonalUp].LineStyle:=xlNone;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlEdgeLeft].LineStyle:=xlContinuous;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlEdgeTop].LineStyle:=xlContinuous;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlEdgeBottom].LineStyle:=xlContinuous;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlEdgeRight].LineStyle:=xlContinuous;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlInsideVertical].LineStyle:=xlContinuous;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlInsideHorizontal].LineStyle:=xlContinuous;
end;
 
多人接受答案了。
 
后退
顶部