你可以让用户选择字段,将数据送到Excel或Word中,具体可参考‘也要问Delphi与Excel连接’
解决方案 »
- delphi中对单表进行查询,帮我看看应该怎么改!
- 这个程序如何解决啊????
- 如何实现oracle数据库记录的唯一性?
- 基础问题:如何利用ado存取access数据库?在线等~
- 打印的字体问题
- Delphi 7如何做XP效果?
- DBGrid 小问题???
- 如何把delphi函数或过程转化为16进制代码
- 怎么解决象死机一样的问题,我用了Application.ProcessMessage还不行,?为什么看看。在线等候
- 请举例说明一下try在delphi里的作用和地位,以及必要性!谢谢
- 请问“cannot focus a disabled or invisible window"是什么问题?
- 请教各位:CreateWindowStation/CreateDesktop为什么会出错?
你可以让用户选择字段,将数据送到Excel或Word中,具体可参考‘也要问Delphi与Excel连接’
建议用支持打印GRID的构件,做动态报表就很容易了
支持打印dbgrid的构件指什么?我不了解,能否详细指教?拜托各位,,帮帮俺,,,能是新手,可是在做项目啊,,,//cry
还要各位高手指点呢
可以直接把DBGRID的数据打印出来。当然还要设置表头等信息。
你可以下载EHLIB构件(www.51delphi.com)它有DEMO你可以看看
procedure TYw_Assess_Query_Frm.MakeRep;
var
Total,i:integer;
QRLabeltitle,QRLabelfooter:tqrlabel;
QRsysdata:TQRsysdata;
begin
tbl_accessqry.Active:=true;
QRep:=TQuickRep.Create(self);
QRep.parent:=self;
QRep.Top:=400;
QRep.Left:=0;
QRep.DataSet:=tbl_accessqry;
QRep.Bands.HasTitle:=true; {指定其具有标题}
QRep.Bands.HasColumnHeader:=true; {指定其具有列头}
QRep.Bands.HasDetail:=true; {指定其具有列值}
QRep.Bands.HasPageFooter:=true; {指定其具有页脚}
// QRep.AfterPreview:=FreeRept; //FreeRept是一个过程,在
//过程中自动释放掉报表
total:=tbl_accessqry.Fields.Count;
SetLength(QRLabel,total);
SetLength(QrdbText,total);
{动态创建报表标题}
QRLabeltitle:=TQRLabel.Create(QRep.Bands.TitleBand);
QRLabeltitle.parent:=QRep.Bands.TitleBand;
// QRLabeltitle.Top:=QRep.Bands.titleBand.Top+2;
QRLabeltitle.height:=QRep.Bands.TitleBand.height-2;
if total<7
then
QRLabeltitle.left:=180
else
QRLabeltitle.left:=230;
QRLabeltitle.caption:='工作考核统计表';
QRLabeltitle.Font.Name:='隶书';
QRLabeltitle.Font.size:=26;
QRLabeltitle.Font.Style:=[fsbold];
// QRLabeltitle.Font.Style:=[fsunderline];
// QRLabeltitle.frame.drawbottom:=true;
// QRLabeltitle.frame.style:=pssolid;
//QRLabeltitle.frame.Width:=1;
total:=tbl_accessqry.Fields.Count;
SetLength(QRLabel,total); QRLabelfooter:=TQRLabel.Create(QRep.Bands.PageFooterband);
QRLabelfooter.parent:=QRep.Bands.PageFooterband;
QRLabelfooter.height:=QRep.Bands.PageFooterband.height-2;
QRLabelfooter.caption:='印单日期';
QRLabelfooter.left:=430;
QRLabelfooter.Font.size:=14;
QRLabelfooter.Font.Style:=[fsbold];
QRsysdata:=TQRsysdata.Create(QRep.Bands.PageFooterband);
QRsysdata.parent:=QRep.Bands.PageFooterband;
QRsysdata.height:=QRep.Bands.PageFooterband.height-2;
QRsysdata.Data:=qrsDateTime;
QRsysdata.left:=530;
QRsysdata.Font.size:=12;
QRsysdata.Font.Style:=[fsbold];
QRsysdata.Font.Style:=[fsunderline];
QRsysdata.Frame.Style:=pssolid;
For i:=0 to total - 1 do
begin
QRLabel[i]:=TQRLabel.Create(QRep.Bands.ColumnHeaderBand);
QRLabel[i].parent:=QRep.Bands.ColumnHeaderBand;
QRLabel[i].height:=QRep.Bands.ColumnHeaderBand.height-2;
// QRLabel[i].width:=8*tbl_accessqry.Fields[i].datasize; {一个字8个字节}
QRLabel[i].width:=tbl_accessqry.Fields[i].DisplayWidth;
// QRLabel[i].AutoSize:=false;
QRLabel[i].Font.size:=10;
// QRLabel[i].Font.Style:=[fsbold];
QRLabel[i].frame.drawbottom:=true; {指定Text是否有边框}
QRLabel[i].frame.drawleft:=true;
QRLabel[i].frame.drawright:=true;
QRLabel[i].frame.drawtop:=true;
QRLabel[i].Top:=1;
if i=0
then
QRLabel[i].Left:=0
else
QRLabel[i].left:=QRlabel[i-1].left+QRLabel[i-1].width;
QRLabel[i].Caption:=tbl_accessqry.Fields[i].DisplayLabel;
{ with query1 do
begin
close;
sql.clear;
sql.add('select * from wx_assess_setting where assess_setting_name2=:str');
params[0].AsString:=tbl_accessqry.Fields[i].DisplayLabel;
showmessage(tbl_accessqry.Fields[i].DisplayLabel);
prepare;
open;
end;
QRLabel[i].Caption:=query1.fieldbyname('assess_setting_name1').asstring; }
end;
{动态生成列值}
For i:=0 to total - 1 do
begin
QrdbText[i]:=TQrdbText.Create(QRep.Bands.DetailBand);
QrdbText[i].parent:=QRep.Bands.DetailBand;
QrdbText[i].Autosize:=false;
QrdbText[i].height:=QRep.Bands.DetailBand.height;
QrdbText[i].top:=-2;
QrdbText[i].width:= QRLabel[i].width;
// QrdbText[i].AutoSize:=false;
QrdbText[i].Alignment:=tacenter;
if i=0
then
QrdbText[i].Left:=0
else
QrdbText[i].left:=QrdbText[i-1].left+QrdbText[i-1].width;
QrdbText[i].frame.drawbottom:=true; {指定Text是否有边框}
QrdbText[i].frame.drawleft:=true;
QrdbText[i].frame.drawright:=true;
QrdbText[i].frame.drawtop:=true;
QrdbText[i].Dataset:=tbl_accessqry;
QrdbText[i].DataField:=tbl_accessqry.Fields[i].fieldname;
end;
end;
{释放动态创建报表的所有控件空间}
procedure TYw_Assess_Query_Frm.RepFree;
var i:integer;
begin
for i:=0 to ComponentCount-1 do
begin
if (Components[i].ClassType=TQRLabel) or (Components[i].ClassType=TQrdbText) then
begin
TQRLabel(Components[i]).Free;
TQrdbText(Components[i]).Free;
end;
end;
Qrep.Free;
//QRLabeltitle.Free;
//QRLabelfooter.Free;
//QRsysdata.Free;
end;
{打印功能的实现}
procedure TYw_Assess_Query_Frm.btn_printClick(Sender: TObject);
begin
MakeRep;
QRep.Preview;
RepFree;
end;
还有如果你看见这个帖子,你给我的程序我运行有一点小问题,上线不能封死啊,,怎么办啊??
救命,,,