【问题标题】:Export webpage to Word in ASP在 ASP 中将网页导出到 Word
【发布时间】:2011-11-30 04:12:22
【问题描述】:

我想在网页顶部添加一个按钮,单击该按钮应将整个网页复制到 MS Word 文档中。 这必须在 ASP 中完成。

【问题讨论】:

    标签: asp-classic ms-word


    【解决方案1】:

    1) 首先在服务器上创建一个 .doc 文件。然后创建一个文件系统对象并使用它来打开 .doc 文件并写入:

    Set file = CreateObject("Scripting.FileSystemObject")
    Set wordFile = file.CreateTextFile(pathToYourDocFile, true)
    wordFile.WriteLine(htmlOutput)
    wordFile.close
    

    "htmlOutput" 必须包含您要导出为 word 的页面。

    2) 另一种选择是直接使用 Word 实例作为mentioned on MSDN

    Set wordApp = GetObject(, "Word.Application")
    wordApp.Visible = False
    wordApp.Documents.Open pathToYourDocFile
    Set wordApp = Nothing
    

    您需要挖掘through the Word API 才能将内容写入文档。

    3) 更改页面的内容类型将自动在 Word 中打开它(如果安装在客户端上):

    Response.ContentType = "application/msword"
    

    【讨论】:

      猜你喜欢
      • 2012-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-31
      • 2011-11-13
      • 1970-01-01
      • 2010-09-21
      • 1970-01-01
      相关资源
      最近更新 更多