<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## 需求 - ? ? ? 有一批word文檔需要以網頁的形式呈現給用戶. - ? ? ? 需要實現動態更新 ## 解決方案 ? ? ? 方案一:? ? ? ?? ? ? ? 建立數據庫,把word中的內容放到數據庫中去,分別設置不同的字段,通過查詢數據庫的方式將內容呈現到網頁中。這是我最開始的解決思路,但是分析word文檔的內容以后發現建立數據庫的方案并不可行,原因是word文檔的內容格式不統一,比如1.docx的排版是標題+圖片+文字介紹+流程圖,2.docx的排版是標題+圖片+表格+文字介紹,這樣設計數據庫的時候比較麻煩,一來是圖片存儲不方便,二來存在字段為空展示頁面的時候沒有統一的模板的問題。 ? ? 方案二: ? ? 把所有的word文檔手工編輯成html。這個方案立馬就被否決了,首先word文件有幾十個,其次后期更新比較困難。 ? ? 方案三: ? ? word直接轉成HTML.這個方案是和[小郎哥](http://blog.csdn.net/solomonlangrui)討論以后,大神寫了一個C#版本的word2html命令行工具。這個方案完一步到位實現了由word到html的質變,簡潔粗暴!C#實現命令行轉html的方法見博客[《C#實現的word轉html命令行工具》](http://blog.csdn.net/solomonlangrui/article/details/47168449)。word2html.exe洗完后html效果和word對比如下圖,可以看出生成的html頁面與原始文檔相比圖片位置略有不同,測試發現word中圖片的插入方式會影響最終的生成效果,基本上實現了需求。 ? ? ? ? ? ? ? ??![](https://box.kancloud.cn/2016-02-26_56cfbdd44d35b.jpg) ## java調用可執行程序 java提供了exec()方法調用外部可執行程序。(java也有實現word轉html的方法,而且不止一種,poi、[jacob](http://www.cnblogs.com/qingxinblog/articles/3399454.html)等都可以。)?java調用外部可執行程序方法如下: ~~~ package com.wordtohtml; public class WordToHtml { public static void main(String[] args) { Runtime rn = Runtime.getRuntime(); Process p = null; String word2html = "";//命令語句 String fileArray[] = new String[] { "1mantou-ts.docx", "2huajuan-ts.docx", "3laobing-ts.docx", "4qiemian-ts.docx","5xianshimian-ts.docx", "6guamian-ts.docx", "7fangbianmian-ts.docx", "8youtiao-ts.docx", "9baozi-ts.docx", "10sudongshuiiao-ts.docx", "11sudonghundun-ts.docx","12doubao-ts.docx", "13fangbianmifan-ts.docx","14fangbianzhou-ts.docx", "15mifen-ts.docx","16surongmifen.docx", "17penghuamibing.docx", "18migaots.docx","19tangyuan-ts.docx", "20yuanxiao-ts.docx", "21miba-ts.docx","22zongzi-ts.docx", "23renxingbinggan-ts.docx", "24suxingbinggan-ts.docx", "25sudabinggan-ts.docx", "26mianbaoyibangongyi-ts.docx", "27eluosimianbao-ts.docx","28meiguomianbao-ts.docx", "29ribenmianbao-ts.docx","30faguomianbao-ts.docx", "31yingguomianbao-ts.docx", "32deguomianbao-ts.docx", "33yidalimianbao-ts.docx","34jianadamianbao-ts.docx", "35dangaoyibangongyi-ts.docx", "36tianshidiangao-ts.docx", "37haimiandangao-ts.docx","38zhongnaiyoudangao-ts.docx", "39qifengdangao-ts.docx", "40zhongnailaodangao-ts.docx", "41qingnailaodangao-ts.docx","42musidangao-ts.docx", "43tongxinfen-ts.docx","44pisabingpi-ts.docx", "45shousi-ts.docx", };//word文件名數組 try { for (int i = 0; i < fileArray.length; i++) { word2html = "WebContent/W2H/word2html.exe ../upload/doc/"+ fileArray[i]; //循環轉換所有word文件 p = rn.exec(word2html);//調用exec()方法 } } catch (Exception e) { e.printStackTrace(); } } } ~~~ word2html.exe位于WebContent/W2H文件夾下,WordToHtml.java位于src目錄下,word文件位于WebContent/upload/doc文件夾下? . 在DOS命令行下執行方式和在java下執行本質上沒有區別,java中調用的時候注意文件路徑。 ? ? ? ? ? ? ? ?![](https://box.kancloud.cn/2016-02-26_56cfbdd478efb.jpg) ## 總結 - ? ?需求實現程度90%(高了?),word文件轉換存在圖片位置瑕疵,圖片轉換后有毛邊。 - ? ?執行時間:轉換45個word文件5秒左右(本機配置:Win7 64bit,i5 CPU,8gRAM,SSD,讀取word文件需要OS多次 ?IO讀取磁盤,在普通硬盤上轉換時間會加長). - ?后期需要實現word上傳至WebContent/upload/doc文件夾下,自動轉換成html并更新前端頁面;獲取.docx格式文件名需要自動實現。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看