• 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";

  • 相关阅读:
    日常小算法
    美化type="file"控件
    流文件_从网络中获取文件
    Kibana配置安装
    JDK安装
    Node.js安装windows环境
    RabbitMQ高可用
    RabbitMQ实例C#
    RabbitMQ基础命令rabbitmqctl
    RabbitMQ配置
  • 原文地址:https://www.cnblogs.com/lrjxgl/p/3078267.html
Copyright © 2020-2023  润新知