CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
IBM Rational 系统开发最佳实践工具包 WebSphere MQ 最佳实践 TOP 15
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Delphi >  数据库相关

求助高手fastReport导出Word

楼主yjp(风)2006-03-03 22:36:34 在 Delphi / 数据库相关 提问

请问怎样将fastReport导出Word中,并且排版格式不变,  
      偶试过在加入frRTFExport控件   ,保存文件,发现排版格式和以前大有差异,  
      用的fastReport的版本是2.5 问题点数:100、回复次数:1Top

1 楼lovendII(流氓都做了城管)回复于 2006-03-04 08:15:46 得分 0

我已用word写好了一个模板,里面放了固定的格式,并定义了很多相应的书签,  
  现在的问题是如何向word文档里对应的书签中加入相应的数据并设置的字体。  
  最好能给出例子。      
   
  ///////////////  
   
  给你一个我刚刚编写的例子,你自己研究:  
   
  unit   Unit1;  
   
  interface  
   
  uses  
      Windows,   Messages,   SysUtils,   Classes,   Graphics,   Controls,   Forms,   Dialogs,  
      StdCtrls;  
   
  type  
      TForm1   =   class(TForm)  
          Button1:   TButton;  
          procedure   InsertLines(LineNum:Integer);  
          procedure   Button1Click(Sender:   TObject);  
      private  
          {   Private   declarations   }  
      public  
          wordApp,wordDoc:Variant;  
          {   Public   declarations   }  
      end;  
   
  var  
      Form1:   TForm1;  
   
  implementation  
   
  uses   ComObj;  
   
  Const   wdAlignParagraphLeft=0;  
  Const   wdAlignParagraphCenter=1;  
  Const   wdAlignParagraphRight=2;  
  Const   wdAlignParagraphJustify=3;  
  Const   wdAdjustNone=0;  
  Const   wdGray25=16;  
  Const   wdGoTOLine=3;  
  Const   wdGoToLast=-1;  
  Const   wdSendToNewDocument=0;  
   
  {$R   *.DFM}  
   
  //在文档中插入空行  
  procedure   TForm1.InsertLines(LineNum:Integer);  
  var  
      iCount:Integer;  
  begin  
      for   iCount:=1   to   LineNum   do  
          wordApp.Selection.TypeParagraph;  
  end;  
   
  procedure   TForm1.Button1Click(Sender:   TObject);  
  var  
      StrAdd:String;  
      i:Integer;  
      wrdSelection:Variant;  
  begin  
      //创建一个word对象  
      wordApp:=CreateOleObject('Word.Application');  
      wordApp.Visible:=true;  
      //创建一个word文档  
      wordDoc:=wordApp.Documents.Add();  
      wordDoc.Select;  
   
      wrdSelection:=wordApp.selection;  
   
      //在文档中插入内容  
      StrAdd:='教务管理员职务说明书';  
      wrdSelection.ParagraphFormat.Alignment:=wdAlignParagraphCenter;  
      wrdSelection.font.bold:=true;  
      wrdSelection.font.size:=15;  
      wrdSelection.font.Underline:=1;  
      wrdSelection.TypeText(StrAdd);  
   
      wrdSelection.font.Underline:=0;  
      wrdSelection.font.bold:=false;  
      wrdSelection.font.size:=11;  
      InsertLines(1);  
   
      //在文档中插入一个4行4列的表格,并格式化  
      wordDoc.Tables.Add(wrdSelection.Range,4,4,2,0);  
      wordDoc.Tables.Item(1).Borders.Item(1).LineStyle:=7;  
      wordDoc.Tables.Item(1).Borders.Item(2).LineStyle:=7;  
      wordDoc.Tables.Item(1).Borders.Item(3).LineStyle:=7;  
      wordDoc.Tables.Item(1).Borders.Item(4).LineStyle:=7;  
      for   i:=1   to   4   do  
      begin  
          wordDoc.Tables.Item(1).Cell(i,1).Range.Bold:=true;  
          wordDoc.Tables.Item(1).Cell(i,3).Range.Bold:=true;  
          wordDoc.Tables.Item(1).Rows.Item(i).Range.Paragraphs.Alignment:=wdAlignParagraphCenter;  
      end;  
      //在第一个表格中插入内容  
      wordDoc.Tables.Item(1).Cell(1,1).Range.text:='岗位名称';  
      worddoc.tables.item(1).cell(1,2).range.InlineShapes.AddPicture('E:\heartsong\0003.gif',False,True);  
      wordDoc.Tables.Item(1).Cell(2,1).Range.InsertAfter('岗位级别');  
      wordDoc.Tables.Item(1).Cell(3,1).Range.InsertAfter('隶属部门');  
      wordDoc.Tables.Item(1).Cell(4,1).Range.InsertAfter('直接上级');  
      wordDoc.Tables.Item(1).Cell(1,3).Range.InsertAfter('岗位编号');  
      wordDoc.Tables.Item(1).Cell(2,3).Range.InsertAfter('现任职者');  
      wordDoc.Tables.Item(1).Cell(3,3).Range.InsertAfter('分支机构');  
      wordDoc.Tables.Item(1).Cell(4,3).Range.InsertAfter('直接下级');  
   
      //插入一个5行一列的表格:工作概述  
      wordApp.Selection.GoTo(wdGotoLine,wdGoToLast);  
      wrdSelection.ParagraphFormat.Alignment:=wdAlignParagraphLeft;  
   
      wordDoc.Tables.Add(wrdSelection.Range,1,1,2,0);  
      wordDoc.Tables.Item(1).Rows.Item(5).Range.Paragraphs.Alignment:=wdAlignParagraphLeft;  
   
      wrdSelection.Font.Bold:=true;  
      wrdSelection.Font.Size:=13;  
      wrdSelection.TypeText('一、工作概述:');  
      wrdSelection.font.bold:=false;  
      wrdSelection.Font.Size:=11;  
      wrdSelection.TypeText(chr(10)+'一些内容');  
   
      //插入一个5行一列的表格:主要工作职责  
      wordApp.Selection.GoTo(wdGotoLine,wdGoToLast);  
      wrdSelection.ParagraphFormat.Alignment:=wdAlignParagraphLeft;  
       
      wordDoc.Tables.Add(wrdSelection.Range,1,1,2,0);  
      wordDoc.Tables.Item(1).Rows.Item(6).Range.Paragraphs.Alignment:=wdAlignParagraphLeft;  
   
      wrdSelection.Font.Bold:=true;  
      wrdSelection.Font.Size:=13;  
      wrdSelection.TypeText('二、主要工作职责:');  
      wrdSelection.font.bold:=false;  
      wrdSelection.Font.Size:=11;  
      wrdSelection.TypeText(chr(10)+'一些内容');  
   
      //插入一个5行一列的表格:工作关系:  
      wordApp.Selection.GoTo(wdGotoLine,wdGoToLast);  
      wrdSelection.ParagraphFormat.Alignment:=wdAlignParagraphLeft;  
       
      wordDoc.Tables.Add(wrdSelection.Range,1,1,2,0);  
      wordDoc.Tables.Item(1).Rows.Item(7).Range.Paragraphs.Alignment:=wdAlignParagraphLeft;  
   
      wrdSelection.Font.Bold:=true;  
      wrdSelection.Font.Size:=13;  
      wrdSelection.TypeText('三、工作关系:');  
      wrdSelection.font.bold:=false;  
      wrdSelection.Font.Size:=11;  
      wrdSelection.TypeText(chr(10)+'一些内容');  
   
      //插入一个5行一列的表格:工作权限:  
      wordApp.Selection.GoTo(wdGotoLine,wdGoToLast);  
      wrdSelection.ParagraphFormat.Alignment:=wdAlignParagraphLeft;  
       
      wordDoc.Tables.Add(wrdSelection.Range,1,1,2,0);  
      wordDoc.Tables.Item(1).Rows.Item(8).Range.Paragraphs.Alignment:=wdAlignParagraphLeft;  
   
      wrdSelection.Font.Bold:=true;  
      wrdSelection.Font.Size:=13;  
      wrdSelection.TypeText('四、工作权限:');  
      wrdSelection.font.bold:=false;  
      wrdSelection.Font.Size:=11;  
      wrdSelection.TypeText(chr(10)+'一些内容');  
   
      //插入一个5行一列的表格:任职资格与要求:  
      wordApp.Selection.GoTo(wdGotoLine,wdGoToLast);  
      wrdSelection.ParagraphFormat.Alignment:=wdAlignParagraphLeft;  
       
      wordDoc.Tables.Add(wrdSelection.Range,1,1,2,0);  
      wordDoc.Tables.Item(1).Rows.Item(9).Range.Paragraphs.Alignment:=wdAlignParagraphLeft;  
   
      wrdSelection.Font.Bold:=true;  
      wrdSelection.Font.Size:=13;  
      wrdSelection.TypeText('五、任职资格与要求::');  
      wrdSelection.font.bold:=false;  
      wrdSelection.Font.Size:=11;  
      wrdSelection.TypeText(chr(10)+'学历:'+'一些内容');  
      wrdSelection.TypeText(chr(10)+'工作经历:'+'一些内容');  
      wrdSelection.TypeText(chr(10)+'要求具备的胜任特质:'+'一些内容');  
   
      //插入编制人等内容  
      wordApp.Selection.GoTo(wdGotoLine,wdGoToLast);  
      wrdSelection.ParagraphFormat.Alignment:=wdAlignParagraphLeft;  
   
      //编制人编制日期  
      wrdSelection.Font.Bold:=true;  
      wrdSelection.TypeText('编制人:');  
      wrdSelection.Font.Bold:=false;  
      wrdSelection.TypeText('编制人'+'                               ');  
   
      wrdSelection.Font.Bold:=true;  
      wrdSelection.TypeText('编制日期:');  
      wrdSelection.Font.Bold:=false;  
      wrdSelection.TypeText('编制日期');  
   
      InsertLines(1);  
   
      //审核人审核日期  
      wrdSelection.Font.Bold:=true;  
      wrdSelection.TypeText('审核人:');  
      wrdSelection.Font.Bold:=false;  
      wrdSelection.TypeText('审核人'+'                               ');  
   
      wrdSelection.Font.Bold:=true;  
      wrdSelection.TypeText('审核日期:');  
      wrdSelection.Font.Bold:=false;  
      wrdSelection.TypeText('审核日期');  
   
      InsertLines(1);  
   
      //批准人批准日期  
      wrdSelection.Font.Bold:=true;  
      wrdSelection.TypeText('批准人:');  
      wrdSelection.Font.Bold:=false;  
      wrdSelection.TypeText('批准人'+'                               ');  
   
      wrdSelection.Font.Bold:=true;  
      wrdSelection.TypeText('批准日期:');  
      wrdSelection.Font.Bold:=false;  
      wrdSelection.TypeText('批准日期');  
   
      InsertLines(1);  
   
      //操作员操作日期  
      wrdSelection.Font.Bold:=true;  
      wrdSelection.TypeText('操作员:');  
      wrdSelection.Font.Bold:=false;  
      wrdSelection.TypeText('操作员'+'                               ');  
   
      wrdSelection.Font.Bold:=true;  
      wrdSelection.TypeText('操作日期:');  
      wrdSelection.Font.Bold:=false;  
      wrdSelection.TypeText('操作日期');  
   
      //保存文档  
   
  end;  
   
  end.  
  Top

相关问题

  • 关于导出WORD文档
  • pb报表导出WORD格式
  • 求WORD文档导出PDF的代码
  • .net下C# word文档导入导出
  • 求把excel 导出到 word的方法
  • 求把excel 导出到 word的方法
  • 在vc中怎样导出word
  • ACCESS报表导出到WORD格式
  • 有关Web网页导出到Word中问题---导出后要分页
  • 急!求高手指点。关于FASTREPORT导出EXCEL问题?

关键词

  • word
  • fastreport
  • linenum
  • tform
  • 格式
  • const
  • procedure
  • integer
  • button
  • var

得分解答快速导航

  • 帖主:yjp

相关链接

  • Delphi类图书
  • Delphi类源码下载
  • Delphi控件下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo