• php html保存word方法


    网上找的修改打开默认视图不是web视图的问题

    <?php

    class word
    {
    function start()
    {
    ob_start();
    echo '<html xmlns:v="urn:schemas-microsoft-com:vml"
    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>
    <!--[if gte mso 9]><xml>
    <o:DocumentProperties>

    <o:Author>MC SYSTEM</o:Author>
    <o:LastAuthor>MC SYSTEM</o:LastAuthor>
    <o:Revision>2</o:Revision>
    <o:TotalTime>1</o:TotalTime>
    <o:Created>2012-05-31T14:42:00Z</o:Created>
    <o:LastSaved>2012-05-31T14:42:00Z</o:LastSaved>
    <o:Pages>1</o:Pages>
    <o:Characters>5</o:Characters>
    <o:Company>MC SYSTEM</o:Company>
    <o:Lines>1</o:Lines>
    <o:Paragraphs>1</o:Paragraphs>
    <o:CharactersWithSpaces>5</o:CharactersWithSpaces>
    <o:Version>11.5606</o:Version>
    </o:DocumentProperties>
    </xml><![endif]--><!--[if gte mso 9]><xml>
    <w:WordDocument>
    <w:View>Print</w:View>
    <w:SpellingState>Clean</w:SpellingState>
    <w:GrammarState>Clean</w:GrammarState>
    <w:PunctuationKerning/>
    <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
    <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
    <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
    <w:ValidateAgainstSchemas/>
    <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
    <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
    <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
    <w:Compatibility>
    <w:SpaceForUL/>
    <w:BalanceSingleByteDoubleByteWidth/>
    <w:DoNotLeaveBackslashAlone/>
    <w:ULTrailSpace/>
    <w:DoNotExpandShiftReturn/>
    <w:AdjustLineHeightInTable/>
    <w:BreakWrappedTables/>
    <w:SnapToGridInCell/>
    <w:WrapTextWithPunct/>
    <w:UseAsianBreakRules/>
    <w:DontGrowAutofit/>
    <w:UseFELayout/>
    </w:Compatibility>
    <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
    </w:WordDocument>
    </xml><![endif]--><!--[if gte mso 9]><xml>
    <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
    </w:LatentStyles>
    </xml><![endif]-->
    </head>
    <body>';
    }
    function save($path)
    {
    echo "</body>
    </html>";
    $data = ob_get_contents();
    ob_end_clean();

    $this->wirtefile ($path,$data);
    }

    function wirtefile ($fn,$data)
    {
    $fp=fopen($fn,"wb");
    fwrite($fp,$data);
    fclose($fp);
    }
    }



    $word = new word();
    $word->start();
    //$html = "aaa".$i;
    $wordname ="2.doc";
    $html=$_POST['content'];
    echo iconv("utf-8","gbk",$html);
    $word->save($wordname);
    ob_flush();//每次执行前刷新缓存
    flush();
    echo "success";

  • 相关阅读:
    第51天 [js] 字符串相连有哪些方式?哪种最好?为什么?
    第52天 [js] 什么是事件委托?它有什么好处?能简单的写一个例子吗?
    np.ndarray与Eigen::Matrix之间的互相转换
    C++向assert加入错误信息
    CeiT:训练更快的多层特征抽取ViT
    CoAtNet: 90.88% Paperwithcode榜单第一,层层深入考虑模型设计
    正式启用Danube 官方站点
    go 编译报错 package embed is not in GOROOT (/usr/local/go/src/embed)
    cloudreve兼容acme.sh脚本
    Git的交叉编译
  • 原文地址:https://www.cnblogs.com/lrjxgl/p/3078267.html
Copyright © 2020-2023  润新知