rtf富文本

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access.

在本教程中,我将向您展示如何在网站上提供动态的RTF文档,该文档是根据数据库中的数据生成的。 对于本教程,您将需要Microsoft Word或写字板,WhizBase和Microsoft Access。

In this tutorial I will show you how to make RTFs with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html

在本教程中,我将向您展示如何使用WhizBase来制作RTF,如果您想了解有关WhizBase的更多信息,请阅读我以前的文章, 网址为http://www.experts-exchang e.com/ARTH _5123186.h tml

Create your document

建立文件

First you need to make an RTF template, it is how the document will look like. I have created a file which lists the first name, last name, telephone, email and address in a table.

首先,您需要制作一个RTF模板,这就是文档的外观。 我创建了一个文件,该文件在表中列出了名字,姓氏,电话,电子邮件和地址。

As you can see the dynamic part will contain WhizBase code.  I have putted $wbf[fname], $wbf[lname], $wbf[email], $wbf[tel] and $wbf[address] in the cells I want to show dynamic data.

如您所见,动态部分将包含WhizBase代码。 我已将$ wbf [fname],$ wbf [lname],$ wbf [email],$ wbf [tel]和$ wbf [address]放在要显示动态数据的单元格中。

These placeholders will be replaced dynamically with data.

这些占位符将动态替换为数据。

Now just save the document as RTF file. You go to "Save As" and save the file as "form.rtf".

现在,只需将文档另存为RTF文件即可。 您转到“另存为”并将文件另存为“ form.rtf”。

Create you database file

创建您的数据库文件

The database can be in any format, I will use Microsoft Access because it is the easiest for me. You can use MySQL, Oracle, MS SQL or even Microsoft Excel.

数据库可以是任何格式,我将使用Microsoft Access,因为它对我来说最简单。 您可以使用MySQL,Oracle,MS SQL甚至Microsoft Excel。

I will create a database file with one table "contacts", it will contain these 6 fields:

我将使用一个表“ contacts”创建一个数据库文件,其中将包含以下6个字段:

ID – autonumaber and primary key
Fname – text
Lname – text
Email – text
Tel – text
Address – memo

Now save this file as "form.mdb"

现在将此文件另存为“ form.mdb”

I have inserted some records in this table.

我在此表中插入了一些记录。

Create WhizBase file

创建WhizBase文件

Finally we need a file which will be our webpage which takes the ID and gives us the RTF document. So we need to implement an input form for ID, and when submit is clicked then start downloading the new generated file.

最后,我们需要一个文件,该文件将成为我们的网页,其中包含ID并提供给我们RTF文档。 因此,我们需要实现ID的输入表单,然后单击“提交”,然后开始下载新生成的文件。

First let's rename the file "form.rtf" to "form.ic", "ic" is the extension for included files in WhizBase by the function $wbrinc.

首先让我们将文件“ form.rtf”重命名为“ form.ic”,“ ic”是功能$ wbrinc在WhizBase中包含文件的扩展名。

Now create an HTML file with this code:

现在使用以下代码创建一个HTML文件:

<html><body><form action='form.wbsp' method='post'>Insert ID: <input type='text' name='wbf_id' /><input type='submit' value='Export file' /></form></body></html>

This is a very basic HTML form file, the only thing you must not forget is the name of the text field, it will be wbf_id, which I have already explained in previous tutorials. Save this file as "default.wbsp".

这是一个非常基本HTML表单文件,您唯一不能忘记的是文本字段的名称,它将是wbf_id,我在之前的教程中已经对此进行了解释。 将此文件另存为“ default.wbsp”。

Now we create another WhizBase file where we query the DB and include the RTF template file.

现在,我们创建另一个WhizBase文件,在其中查询数据库并包含RTF模板文件。

[FormFields]
WB_BaseName=form.mdb
WB_Command=Q
WB_RcdSet=contacts
WB_ShowLogo=F
wb_contenttype=application/msword
<!--WB_BeginTemplate-->
$wbrinc[form.ic]

As you can see nothing new, we are simply querying the DB and including the template which have the placeholders which will be replaced with data. The only important and new thing is the line:

如您所见,没有什么新鲜的东西,我们只是在查询数据库,并包括具有占位符的模板,这些占位符将被数据替换。 唯一重要的新事物是该行:

wb_contenttype=application/msword

Here we say to the browser that this documents type is not HTML so do not render it, we say it is MS WORD  application type, so any popular browser will just download it to your computer.

在这里,我们向浏览器说此文档类型不是HTML,所以不要渲染它,而是说它是MS WORD应用程序类型,因此任何流行的浏览器都将其下载到您的计算机上。

And you have now a ready script to make RTF reports easily.

现在,您已经有了准备就绪的脚本,可以轻松制作RTF报告。

For more information please visit my member profile at http://www.experts-exchange.com/M_5123186.html

有关更多信息,请访问我的会员资料, 网址为http://www.experts-exchang e.com/M_51 23186.html

Or visit the WhizBase official site at www.whizbase.com

或访问WhizBase官方网站www.whizbase.com

NurAzije is a PHP and WhizBase programmer, who at the time of article publication has been working in partnership with WhizBase company on several projects and very recently as an employee.

NurAzije是一名PHP和WhizBase程序员,在撰写本文时,他一直与WhizBase公司合作进行多个项目,最近又成为一名员工。

翻译自: https://www.experts-exchange.com/articles/4421/Generate-dynamic-RTF-Rich-Text-Format-documents-easily.html

rtf富文本

rtf富文本_轻松生成动态RTF(富文本格式)文档相关推荐

  1. java解析读取.rtf格式文档

    rtf是开源格式,同时可通过Microsoft Office打开,那么怎么利用java读取.rtf格式的文档呢? package jichu.test_simple;import java.io.Fi ...

  2. 如何删除右键新建 RTF 格式文档的命令

    如何删除右键新建 RTF 格式文档的命令 打开注册表编辑器 按快捷键 Win + R 打开运行窗口,输入 regedit 打开注册表编辑器. 查找需要清除的新建菜单中新建文件的后缀名 鼠标右键单击 计 ...

  3. 关于用java编写生成word文档,动态添加数据到word文档的一些心得

    关于用java编写生成word文档,动态添加数据到word文档的一些心得,经过翻阅了无数的有用的和无用的资料以后,总算找到了一种靠谱的方法 1.概述 经过反反复复的查阅资料,总算找到了一个靠谱的生成w ...

  4. OFDRW提供了将OFD文档导出为其他格式文档的能力,如导出为图片、SVG、PDF、文本等

    OFDRW提供了将OFD文档导出为其他格式文档的能力,如导出为图片.SVG.PDF.文本等. OFDRW 转换模块在 2.0.0 之后抽象了多种文档导出接口,使用统一的 API 实现 OFD 文档导出 ...

  5. javadoc文档的生成方法_Cocoa 代码注释与文档生成

    Cocoa 代码注释与文档生成 本文的文档规范部分的内容参考自:NSHipster 的 Swift Documentation 作者 & Nate Cook 本文知识目录 背景 曾经以为好的代 ...

  6. Java 将xml模板动态填充数据转换为word文档

    需要用到的jar包: commons-codec-1.10.jar freemarker-2.3.21.jar jacob-1.6.jar 实现思路: 1.先将word文档另存为 : Word 200 ...

  7. 在Vs.net中集成 NDoc生成的 Html Help 2帮助文档

    注:NDoc是一个Open Source的For .Net 文档自动生成软件.它可以通过 .Net中XML的注释标签来生成非常漂亮的MSDN风格的类库文档.(相对于VS.Net自己带的Comment ...

  8. 亿愿Word文档批量多语言翻译---word文档翻译专家!几十种语言随意快速互译!可以生成中外文,中英文对照内容文档!

    亿愿Word文档批量多语言翻译-软件功能简介 [亿愿Word文档批量多语言翻译]采用目前最强大的.国际著名公司的谷歌翻译引擎,自动识别语言种类,把英文.日文.韩文.德文.法文.俄文等几十种外国语言的文 ...

  9. 苹果手机怎么编辑word文档_多人协同编辑一份Word文档用修订功能就对了

    在职场中我们难免会遇到需要与同事协同编辑一份文档的情况 那么如何清晰不混乱地协同编辑呢? 如下图所示,相信不少人在协同编辑文档时都是这样做的,用各种颜色字和括号,写明自己想编辑的内容及要修改的点.一旦 ...

最新文章

  1. 【FFmpeg】便捷函数汇总(持续更新中...)
  2. CondaHTTPError: HTTP 404 NOT FOUND for url https://pypi.tuna.tsinghua.edu.cn/simple/ 错误
  3. C语言中动态数组的作用,C语言实现动态数组
  4. 【杂谈】GitHub上有哪些好用的爬虫(从Google百度,腾讯视频抖音,豆瓣知乎到不可描述)
  5. 95后程序员晒出工资单:狠补了这个,真香…
  6. 西门子标准报文1常用_基于Snap7使用C#编程访问西门子PLC系列教程(2)-S7协议
  7. 快速判断一个数是否是4的幂次方,若是,并判断出来是多少次方! .
  8. java_advanced_review(3)补充:利用网络套接字实现类似qq 的控制台通讯
  9. gacutil不是内部或外部命令_Win7命令提示符输入taskkill提示不是内部或外部命令...
  10. 【转】走进windows编程的世界-----对话框、文本框、按钮
  11. [jQuery原理] jQuery属性操作相关方法
  12. js逆向解析技巧--selenium
  13. win7为什么打开桌面上的计算机很卡很慢,如何解决win7系统电脑反应慢
  14. 离线计算框架MapReduce
  15. 0/0型极限等于多少_两个重要极限的一点理解(下)
  16. java加载so包,undefined symbol处理方法
  17. Simpson自适应Simpson
  18. iPhone 自动关机 原因 天气太冷
  19. JS中的for循环解数学题
  20. Python爬虫--Selenium模拟用户的键盘鼠标操作

热门文章

  1. MCE | 肿瘤微环境在癌症中的作用
  2. zao显示服务器错误,ZAO修改用户协议回应质疑 用户内容不会用作他用
  3. VLAN、VXLAN
  4. 数字之积 (数位dp)
  5. 西北大学电影专硕考研考情与难度、参考书及上岸前辈备考经验
  6. SAP ERP数据表清单
  7. Windows 98
  8. 创客教育在空间设计中的服务研究
  9. #华为推送# 游戏类应用如何利用推送能力实现用户运营精细化
  10. 后疫情时代,零售行业有哪些新机遇