简体   繁体   English

在VB.NET中使用RTF创建文档

[英]Using RTF in VB.NET to create a document

Thanks for viewing my post. 感谢您查看我的帖子。 I'm looking for ideas regarding creating a document with rtf. 我正在寻找有关使用rtf创建文档的想法。 I started using word to create a word document automatically, but word automation does not work too well server side, and it is not recommended to do so by Microsoft. 我开始使用Word自动创建Word文档,但是单词自动化在服务器端不能很好地工作,Microsoft不建议这样做。 I know how to do basic text with rtf, but I'm wondering if I could create a template with bookmarks and fill in these bookmarks with data from a database. 我知道如何使用rtf执行基本文本,但是我想知道是否可以创建带有书签的模板,并使用数据库中的数据填充这些书签。 Any ideas would be appreciated. 任何想法,将不胜感激。 I'm not looking for handouts (ex- coding), just looking for ideas. 我不是在寻找讲义(编码),而是在寻找想法。 Thank again for your time! 再次感谢您的宝贵时间! Any info will be greatly appreciated! 任何信息将不胜感激! I'm using asp.net. 我正在使用asp.net。

Josh 玩笑

RTF stand for Rich Text Format. RTF代表RTF格式。 the toolbox contains a RichTextBox control which will read,edit, and write rtf documents. 工具箱包含一个RichTextBox控件,该控件将读取,编辑和写入rtf文档。 You can easily extend this to get the functionality you want. 您可以轻松地扩展它以获得所需的功能。 Here's an example 这是一个例子

Here's an example of a rich text editing control for asp.net 这是asp.net的富文本编辑控件的示例

I'm going to go at this in a new way. 我将以一种新的方式来解决这个问题。 I'm going to create a html document with 'placeholders'. 我将使用“占位符”创建一个html文档。 Then I will call on the document to save with the .doc extension. 然后,我将调用文档以.doc扩展名保存。 Testing has shown that Microsoft Word will open this document. 测试表明Microsoft Word将打开此文档。 Thanks again. 再次感谢。

Josh 玩笑

    Public Function GetTemplate( _
        ByVal strTemplateFile As String) As String

        Dim strPath As String = ""

        strPath = Server.MapPath("~/Templates") & "\" & strTemplateFile
        Return My.Computer.FileSystem.ReadAllText(strPath)


    End Function

and

    Dim strTemplate As String = ""
    Dim blnLB As Boolean = True

    strTemplate = GetTemplate("Legislative_Bulletin.htm")

    Response.AppendHeader("Content-Type", "application/msword")
    Response.AppendHeader("Content-disposition", "attachment; filename=Legislative_Bulletin" & ".doc")
    Response.Write(strTemplate)
    Response.End()

this is just example coding. 这只是示例编码。 you will still need to insert the data into the placeholders of the html template. 您仍然需要将数据插入html模板的占位符。 I hope this helps someone! 我希望这可以帮助别人!

Josh 玩笑

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM