在D7中,如何将数据库中的数据输出到word中,将要求试卷的格式.其中还包括图片.谢谢.

解决方案 »

  1.   

    很多报表控件都支持,去DELPHI盒子找找
      

  2.   

    给你一个,看看吧
    procedure TFxueji.bsSkinSpeedButton6Click(Sender: TObject);
    var
      WdUnit, WdCount, wdExtend: OleVariant;
    num:integer;
    T:table;
    PageNum,i,count:integer;
    filename:string;
    itemindex,tempplate,newtemplate,documenttype,visible:olevariant;
    begin
    PageNum:=1;
    count:=1;
      WdUnit := 1;
      wdCount := 1;
      wdExtend := EmptyParam;
    self.bsSkinOpenDialog1.Filter:='doc files|*.doc';
    if self.bsskinOpenDialog1.Execute then
    begin
    visible:=true;
    documenttype:=0;
    FileName := bsskinOpendialog1.FileName;
          itemindex:=1;
          tempPlate:=Filename;
          newtemplate:=false;
          WordApplication1.Connect;
          WordApplication1.Visible:=true;
          WordApplication1.Documents.Add(TempPlate,newtemplate,documenttype,visible);
          WordDocument1.ConnectTo(WordApplication1.Documents.Item(itemindex));
          WordApplication1.Selection.WholeStory;
          wordapplication1.Selection.Copy;
          wordapplication1.Selection.MoveLeft(WdUnit, wdCount, wdExtend);
          AddPageNum(wordapplication1,1);
          fdm.TAddstudent.First;
          for i:=0 to fdm.TAddstudent.RecordCount-1 do
          begin
          T:=self.WordDocument1.Tables.Item(pagenum);
          t.cell(count+1,1).range.text:=fdm.TAddstudent.fieldbyname('jlh').AsString;
          t.Cell(count+1,2).range.text:=fdm.TAddstudent.fieldbyname('xjh').AsString;
          t.Cell(count+1,3).range.text:=fdm.TAddstudent.fieldbyname('xm').AsString;
          t.Cell(count+1,4).range.text:=fdm.TAddstudent.fieldbyname('xb').AsString;
          t.Cell(count+1,5).range.text:=fdm.TAddstudent.fieldbyname('csny').AsString;
          t.Cell(count+1,6).range.text:=fdm.TAddstudent.fieldbyname('zzmm').AsString;
          t.Cell(count+1,7).range.text:=fdm.TAddstudent.fieldbyname('jtzz').AsString;
          t.Cell(count+1,8).range.text:=fdm.TAddstudent.fieldbyname('rxsj').AsString;
          //t.Cell(count+1,2).range.text:=fdm.TAddstudent.fieldbyname('').AsString;
          //t.Cell(count+1,2).range.text:=fdm.TAddstudent.fieldbyname('xjh').AsString;
          fdm.TAddstudent.Next;
          if count=15 then
             begin
             pagenum:=pagenum+1;
             self.AddNewModalPage(wordapplication1,pagenum);
             count:=1;
             end else
             count:=count+1;
          end;
          //num := WordDocument1.paragraphs.count; //求得模板中的段落总数为38
          //worddocument1.paragraphs.item(num).range.insertafter('aaa');
    end;
    end;
      

  3.   

    楼上的大哥,能联系一下不?48271631我不太会配置你的这个程序.能把写好的代码给我传过来吗[email protected]