将HTML页面保存到MS Word [英] save HTML page to MS Word

查看:98
本文介绍了将HTML页面保存到MS Word的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我使用ColdFusion作为前端。我想将HTML页面保存到Word文档。下面的代码工作正常,但是当我尝试保存或保存为时,默认文件类型是.HTM / .HTML。我怎么做默认文件类型是.doc?



这是代码

Hello,
I am using ColdFusion as front-end. I want to save a HTML page to a Word Document. The below code are work fine, but when I try to save or save As, the default file type is .HTM/.HTML. How do I do to make default file type is .doc?

Here is the codes

<cfsavecontent variable="testMe">
<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'>

    <!--- Head tag instructs Word to start up a certain way, specifically in print view. --->
    <head>
        <xml>
         <w:WordDocument>
            <w:View>Print</w:View>
            <w:view w:val="print" />
            <w:SpellingState>Clean</w:SpellingState>
            <w:GrammarState>Clean</w:GrammarState>
            <w:Compatibility>
            <w:BreakWrappedTables/>
            <w:SnapToGridInCell/>
            <w:WrapTextWithPunct/>
            <w:Zoom>100</w:Zoom>
            <w:UseAsianBreakRules/>
            </w:Compatibility>
            <w:DoNotOptimizeForBrowser/>
         </w:WordDocument>
        </xml>

    </head>
    <body>

        1234 <br>
        <cfoutput>#now()#</cfoutput>
    </body>
</html><a href=""></a>
</cfsavecontent>

<cfoutput>#testMe#</cfoutput>
<cffile action="write" file="#application.reportsDir#eowReports\testMe.doc" output="#testMe#"/>
<br>
<a href="https://trmptudevhp.dev.tdan.mda.mil/mpl_getFile.cfm?folder=eowReports\&fileName=testMe.doc">Open It</a>







谢谢

Hung Pham

pham_mn@yahoo.com




Thank you
Hung Pham
pham_mn@yahoo.com

推荐答案

你不能只修改默认值。首先,那些.doc格式已经过时,你应该使用标准的,基于Open XML标准的.docx。更重要的是,这不是W3标准的一部分,你不能只是转换它。同时,MS Word可以加载HTML文件。简单地将HTML重命名为.doc时的作弊会起作用,但是会很糟糕,没有实际意义。



如果你真的需要将HTML文档转换成单词,你只能在服务器端做到这一点。但解决方案将在很大程度上取决于您的服务器端平台以及您使用的服务器端技术(如果有)。这当然是可能的,但我强烈反对你这样做,除非你与Microsoft Office(很少在网上发生)串联,并准备好投入大量的开发时间。



-SA
You cannot do it by just changing default. First of, those .doc formats are obsolete, you should use standard, based on Open XML standard, .docx. More importantly, this is not a part of W3 standard, you cannot just "convert" it. At the same time, MS Word can load HTML files. The cheating when you simply rename HTML to .doc would work, but would be nasty, making no practical sense.

If you really need to convert the HTML document to word, you can do it only on the server side. But the solution will be heavily depends on what is your server-side platform and what server-side technology you use, if any. It is of course possible, but I would strongly discourage you from doing that, unless you have string bonding with Microsoft Office (which rarely happens on the Web) and are ready to put good amount of development time.

—SA


对所有人抱歉:我应该说我想将HTML页面的内容转换为Word文档然后另存为doc文件。我并不是要重命名文件。



我成功地将HTML页面的内容转换为Word文档,但是当我打开Word文档文件时另存为它是第一次,保存类型默认为* .htm; *。html的。我必须手动选择.doc或.docx才能第一次保存,然后保存类型默认为.doc或.docx。



如何使保存类型默认为.doc或.docx。第一次?



ColdFusion是我的前端。



非常感谢你,对不起没有让自己清楚。





Hung Pham
Sorry to everyone: I should say "I want to convert the CONTENT of a HTML page to a Word document and then Save As the doc file". I did not mean to rename the file.

I am successfully convert the CONTENT of a HTML page to a Word document, but when I open the Word document file and "Save As" it for the first time, the Save as type is default to *.htm; *.html. I have to manually to select .doc or .docx to save for the first time, then after that the Save as type is default to .doc or .docx.

How do I do to make Save as type is default to .doc or .docx. for the first time?

ColdFusion is my front end.

Thank you so much and sorry for not making myself clear.


Hung Pham


你好SA,

原因我需要将HTML页面的内容保存到Word文档中,因为我的客户希望在Word中看到它作为他们的报告。

当他们打开Word报告时,他们可以根据需要进行编辑,之后,他们将保存或保存为,就像我之前提到的那样,当他们第一次保存或保存时,保存类型默认为.htm / .html而不是.doc。他们希望保存类型默认为.doc。

我希望你有意义并且非常感谢你花时间

Hung Pham
Hi SA,
The reason I need to save a content of a HTML page into a Word document because my customers want to see it in Word as their report.
When they open their Word report, they can edit it as they want, and after that they will save or save as , then like I mentioned earlier, when they Save or Save for the first time the save as type default to .htm/.html instead of .doc. They want the save as type default to .doc.
I hope it makes sense to you and thank you so much for taking your time
Hung Pham


这篇关于将HTML页面保存到MS Word的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆