使用HTML&动态生成MS Word文档.的CSS [英] Dynamically generate a MS Word document using HTML & CSS

查看:88
本文介绍了使用HTML&动态生成MS Word文档.的CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

昨天,我读了文章使用HTML和CSS动态生成MS Word文档" 使用HTML动态生成MS Word文档& CSS [ ^ ],我真的喜欢阅读.但是所有这些代码仅适用于ASP而不是PHP.我想开发一个小型应用程序,可以通过PHP生成MS Word文档.
我尝试使用COM,但我不喜欢使用COM对象,因此必须在服务器上安装MS Word才能生成MS Word文档.在我看来,这不是称呼!
我也尝试过HTTP标头,但我不喜欢最终产品.布局是Web而不是Print,页面是纵向而不是横向.

是否可以将用ASP编写的代码改编成PHP?
我将为克服这一小障碍提出一些建设性的建议.

最好的问候,

Peter

Hello everybody!

Yesterday I read the article "Dynamically generate a MS Word document using HTML & CSS" Dynamically generate a MS Word document using HTML & CSS[^] and I really enjoyed read it. But all this code only works on ASP instead PHP. I want develop a small application that can generate a MS word document via PHP.
I tried COM and I didn''t like using COM objects and is necessary MS Word installed on server to generate MS Word document. In my opinion, it''s not appellative!
I also tried HTTP headers but I didn''t like the final product. The layout is Web instead Print, the page is portrait instead landscape.

Is it possible adapt code written in ASP to PHP?
I would appreciate some constructive suggestions to overcome this small obstacle.

Best Regards,

Peter

推荐答案

看看下面的讨论:
http://stackoverflow.com/questions/124959/create-word-document- using-php-in-linux [ ^ ]

Take a look at the following discussion:
http://stackoverflow.com/questions/124959/create-word-document-using-php-in-linux[^]

Same query is discussed in detail.


回答我的问题:是的,有可能使ASP代码适应PHP.

Answering to my question: Yes, it''s possible adapt ASP code to PHP.

<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><title>Time</title>
    <xml>
        <w:worddocument xmlns:w="#unknown">
            <w:view>Print</w:view>
            <w:zoom>90</w:zoom>
            <w:donotoptimizeforbrowser />
        </w:worddocument>
    </xml>
    <style>
        @page Section1
        {size:8.5in 11.0in;
         margin:1.0in 1.25in 1.0in 1.25in ;
         mso-header-margin:.5in;
         mso-footer-margin:.5in; mso-paper-source:0;}
        div.Section1
        {page:Section1;}
    </style>
</head>
<body lang=EN-US style='tab-interval:.5in'>
    <div class="Section1">
<h1>Hello Word!</h1>
    </div>
</body>
</html>





header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=report_".date("d_m_Y_G_i").".doc");
?>



也许您的编辑器PHP可以提醒您一些未知的HTML标签.您必须忽略它.

我要感谢"Anil" Radhakrishna的贡献.



Your editor PHP, maybe, can alert you about some unknown HTML tag . You must ignore it.

I would like to thanks at ''Anil'' Radhakrishna for his contribution.


这篇关于使用HTML&amp;动态生成MS Word文档.的CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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