在 ASP 中将网页导出到 Word

发布于 2024-09-10 04:20:00 字数 62 浏览 1 评论 0原文

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

I would like to add a button on top of a webpage, which when clicked should copy the entire webpage to an MS Word document.
This has to be done in ASP.

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

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

发布评论

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

评论(1

笔落惊风雨 2024-09-17 04:20:00

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

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

“htmlOutput”必须包含要导出到word的页面。

2) 另一种选择是直接使用 Word 实例 MSDN 上提到

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

您需要深入研究Word API< /a> 以便将内容写入文档。

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

Response.ContentType = "application/msword"

1) First create a .doc file on the server. Then create a file system object and use it to open the .doc file and write into it:

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

"htmlOutput" must contain the page you want to export to word.

2) Another option is to directly work with an instance of Word as mentioned on MSDN:

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

You will need to dig through the Word API in order to write content to the document.

3) Change the content tye of your page will automatically opens it in Word (if installed on the client):

Response.ContentType = "application/msword"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文