如何在 Word 或 RTF 文档的表格中显示 DBGrid 的内容?

发布于 2024-09-14 02:15:32 字数 148 浏览 2 评论 0原文

我正在使用 Rave 生成​​报告,但它在生成 Word 文档方面很差。我的报告需求很简单;我在代码中唯一不能轻松做的事情就是制作一个表格。我希望获得有关如何以 Word 或 RTF 兼容格式在边框表中显示 [DB]Grid 内容(或基础 ClientDataSet 记录)的建议。

I'm using Rave to generate reports, but it's poor at generating Word docs. My reporting needs are simple; the only thing I can't do easily within code is make a table. I'd love suggestions about how to display a [DB]Grid's contents (or underlying ClientDataSet records) within a bordered table, in Word or RTF compatible format.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

葵雨 2024-09-21 02:15:32

您可以测试我推荐的相同组件 此处(mx从最大导出)

mxExport可以将TDataset、TStringGrid和TDBGrid导出为不同的文件格式,包括RTF和MS Word。

查看组件并测试演示。它对你可能有用。它是免费的并且包含源代码。 ;-)

You can test the same component that I have recomended here (mxExports from max).

mxExport can export a TDataset, TStringGrid and TDBGrid to differents file formats, including RTF and MS Word.

See the component and test the demos. It can be usefull for you. It's free and source included. ;-)

难以启齿的温柔 2024-09-21 02:15:32

好吧,首先您必须制作一个模板 .doc 文件,您将在其中创建将被替换的关键字...这里是一个示例代码...

<br> 
var
 FileName: OleVariant;
<br> Doc : _Document;
 <br>SearchText, ReplaceText, Wrap, All: OleVariant;
<br>
<br> begin
  <br>WordApplication1.Connect;
  <br>WordApplication1.visible:= True;

 <br> FileName:=GetCurrentDir+'\Documents\In_orders.doc';
  <br>WordApplication1.Documents.Open(FileName,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
  <br>Doc := WordApplication1.ActiveDocument;
  <br>WordDocument1.ConnectTo(Doc);
<br>  WordApplication1.Disconnect;

  <br>SearchText := 'order_nomer';
   <br>ReplaceText := dbgrid1. < some property.. >;
    <br>Wrap := wdFindContinue;
   <br>All := wdReplaceAll;
  <br>WordDocument1.Content.Find.Execute(SearchText, EmptyParam, EmptyParam, EmptyParam,EmptyParam, EmptyParam, EmptyParam, Wrap, EmptyParam, ReplaceText, EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
<br>
 <br>WordApplication1.Disconnect;
 <br>end;

Well, first you have to make a template .doc file, in which you are going to create keywords that are going to be replaced... Here you are one example code...

<br> 
var
 FileName: OleVariant;
<br> Doc : _Document;
 <br>SearchText, ReplaceText, Wrap, All: OleVariant;
<br>
<br> begin
  <br>WordApplication1.Connect;
  <br>WordApplication1.visible:= True;

 <br> FileName:=GetCurrentDir+'\Documents\In_orders.doc';
  <br>WordApplication1.Documents.Open(FileName,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
  <br>Doc := WordApplication1.ActiveDocument;
  <br>WordDocument1.ConnectTo(Doc);
<br>  WordApplication1.Disconnect;

  <br>SearchText := 'order_nomer';
   <br>ReplaceText := dbgrid1. < some property.. >;
    <br>Wrap := wdFindContinue;
   <br>All := wdReplaceAll;
  <br>WordDocument1.Content.Find.Execute(SearchText, EmptyParam, EmptyParam, EmptyParam,EmptyParam, EmptyParam, EmptyParam, Wrap, EmptyParam, ReplaceText, EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
<br>
 <br>WordApplication1.Disconnect;
 <br>end;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文