你可以让用户选择字段,将数据送到Excel或Word中,具体可参考‘也要问Delphi与Excel连接’

解决方案 »

  1.   

    你动态生成控件(比如:LABLE)不就结了!
      

  2.   

    可以用Query把你所需要的内容取出来
    你可以让用户选择字段,将数据送到Excel或Word中,具体可参考‘也要问Delphi与Excel连接’ 
      

  3.   

    我是用delphi自己的报表工具做的,不用Excel能实现吗?老四你好,怎么动态生成?我是用lbl.creat(qband)生成label,用txt.creat(qband)生成数据控件,在执行时可以生成,但是preview时只能看见label上的数据,数据字段的数据显示不出来啊?请帮帮我好吗,。我会给分的,
      

  4.   

    建议不用delphi自己的报表工具
    建议用支持打印GRID的构件,做动态报表就很容易了
      

  5.   

    to sunyanbin(太阳) 
    支持打印dbgrid的构件指什么?我不了解,能否详细指教?拜托各位,,帮帮俺,,,能是新手,可是在做项目啊,,,//cry
      

  6.   

    用reportmathin可能是这么写的他有一个可以打印DBGrid控件的控件不过我不会用〕
    还要各位高手指点呢
      

  7.   

    可以打印DBGrid的控件:
    可以直接把DBGRID的数据打印出来。当然还要设置表头等信息。
    你可以下载EHLIB构件(www.51delphi.com)它有DEMO你可以看看
      

  8.   

     这是我刚做过的动态报表的有关代码,仔细看看就可搞定了,别忘了给我加分啊!!^-^{动态创建报表的过程}
    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;
      

  9.   

    to feismile() 我已经把分送出,可是不能多给,,我在出一个帖子,,你来回,我好送,,
      

  10.   

    felsmile我放了几个帖子找你,你查我的名字去领分啊,,不然我的分不是就在那里悬着吗?
    还有如果你看见这个帖子,你给我的程序我运行有一点小问题,上线不能封死啊,,怎么办啊??
    救命,,,