如何将HTML文件转换为word?

发布于 2024-08-08 18:20:23 字数 1539 浏览 1 评论 0原文

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

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

发布评论

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

评论(5

踏月而来 2024-08-15 18:20:23

尝试使用 pandoc

pandoc -f html -t docx -o output.docx input.html

如果未明确指定输入或输出格式,pandoc将尝试从输入和输出文件名的扩展名中猜测它。
— pandoc 手册

所以你甚至可以使用

pandoc -o output.docx input.html

Try using pandoc

pandoc -f html -t docx -o output.docx input.html

If the input or output format is not specified explicitly, pandoc will attempt to guess it from the extensions of the input and output filenames.
— pandoc manual

So you can even use

pandoc -o output.docx input.html
淤浪 2024-08-15 18:20:23

就在你的 php 页面的顶部。在这方面的任何代码之前应该是顶部代码。

<?php
header("Content-Type: application/vnd.ms-word"); 
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("content-disposition: attachment;filename=Hawala.doc");

?>

这会将所有 html 转换为 MSWORD,现在您可以根据客户要求对其进行自定义。

just past this on head of your php page. before any code on this should be the top code.

<?php
header("Content-Type: application/vnd.ms-word"); 
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("content-disposition: attachment;filename=Hawala.doc");

?>

this will convert all html to MSWORD, now you can customize it according to your client requirement.

眼角的笑意。 2024-08-15 18:20:23

一个不错的选择是使用像 Docverter 这样的 API。 Doverter 将允许您使用 API 将 HTML 转换为 PDF 或 DOCX。

A good option is to use an API like Docverter. Docverter will allow you to convert HTML to PDF or DOCX using an API.

舂唻埖巳落 2024-08-15 18:20:23

执行此操作时,我发现最简单的方法是:

  1. 在 Web 浏览器中访问页面
  2. 使用带有 .htm 扩展名的 Web 浏览器保存页面(可能还有包含支持文件的文件夹)
  3. 启动 Word 并打开保存的 htm 文件(Word 将正确打开它)
  4. 如果需要,进行任何编辑
  5. 选择另存为,然后选择您想要的扩展名 doc、docx 等。

When doing this I found it easiest to:

  1. Visit the page in a web browser
  2. Save the page using the web browser with .htm extension (and maybe a folder with support files)
  3. Start Word and open the saved htmfile (Word will open it correctly)
  4. Make any edits if needed
  5. Select Save As and then choose the extension you would like doc, docx, etc.
此岸叶落 2024-08-15 18:20:23

其他替代方案只是将文件重命名为 .doc.....

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word(office.11​​).aspx

这是一个很好的起点。您还可以尝试使用此 Office Open XML。

http://www.ecma-international.org/publications/standards/ Ecma-376.htm

Other Alternatives from just renaming the file to .doc.....

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word(office.11).aspx

Here is a good place to start. You can also try using this Office Open XML.

http://www.ecma-international.org/publications/standards/Ecma-376.htm

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