導航:首頁 > 文件類型 > html5打開word文件

html5打開word文件

發布時間:2023-02-28 14:42:17

㈠ 在網頁上打開word文檔

編輯好word文檔後,保存為.htm格式的文件
例如,把你的word文檔wendang.doc,保存為wendang.htm,按下面的內去做就容可以。
<a href="http://www..com/wendang.htm">打開</a>
直接點擊打開就可以了

㈡ wpsH5做的文件能不能用word打開

WPS H5文件只能通過連接的方式進行查看,不能再Word文檔中開的。因為H5中的特效動畫無法在Word文檔中顯示。

㈢ 怎麼在網頁中打開word文檔.用代碼實現

將Word轉Html的原理是這樣的:
1、客戶上傳Word文檔到伺服器
2、伺服器調用OpenOffice程序打開上傳的Word文檔
3、OpenOffice將Word文檔另存為Html格式
4、Over
至此可見,這要求伺服器端安裝OpenOffice軟體,其實也可以是MS Office,不過OpenOffice的優勢是跨平台,你懂的。恩,說明一下,本文的測試基於 MS Win7 Ultimate X64 系統
下面就是規規矩矩的實現。
1、下載OpenOffice,
2、下載Jodconverter 這是一個開啟OpenOffice進行格式轉化的第三方jar包。
3、泡杯熱茶,等待下載。

4、安裝OpenOffice,安裝結束後,調用cmd,啟動OpenOffice的一項服務:C:\Program Files (x86)\OpenOffice.org 3\program>soffice -headless -accept="socket,port=8100;urp;"

5、打開eclipse
6、喝杯熱茶,等待eclipse打開。
7、新建eclipse項目,導入Jodconverter/lib 下得jar包。

* commons-io
* jodconverter
* juh
* jurt
* ridl
* slf4j-api
* slf4j-jdk14
* unoil
* xstream

8、Coding...

查看代碼

package com.mzule.doc2html.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ConnectException;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;

/**
* 將Word文檔轉換成html字元串的工具
*
* @author MZULE
*
*/
public class Doc2Html {

public static void main(String[] args) {
System.out
.println(toHtmlString(new File("C:/test/test.doc"), "C:/test"));
}

/**
* 將word文檔轉換成html文檔
*
* @param docFile
* 需要轉換的word文檔
* @param filepath
* 轉換之後html的存放路徑
* @return 轉換之後的html文件
*/
public static File convert(File docFile, String filepath) {
// 創建保存html的文件
File htmlFile = new File(filepath + "/" + new Date().getTime()
+ ".html");
// 創建Openoffice連接
OpenOfficeConnection con = new SocketOpenOfficeConnection(8100);
try {
// 連接
con.connect();
} catch (ConnectException e) {
System.out.println("獲取OpenOffice連接失敗...");
e.printStackTrace();
}
// 創建轉換器
DocumentConverter converter = new OpenOfficeDocumentConverter(con);
// 轉換文檔問html
converter.convert(docFile, htmlFile);
// 關閉openoffice連接
con.disconnect();
return htmlFile;
}

/**
* 將word轉換成html文件,並且獲取html文件代碼。
*
* @param docFile
* 需要轉換的文檔
* @param filepath
* 文檔中圖片的保存位置
* @return 轉換成功的html代碼
*/
public static String toHtmlString(File docFile, String filepath) {
// 轉換word文檔
File htmlFile = convert(docFile, filepath);
// 獲取html文件流
StringBuffer htmlSb = new StringBuffer();
try {
BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(htmlFile)));
while (br.ready()) {
htmlSb.append(br.readLine());
}
br.close();
// 刪除臨時文件
htmlFile.delete();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// HTML文件字元串
String htmlStr = htmlSb.toString();
// 返回經過清潔的html文本
return clearFormat(htmlStr, filepath);
}

/**
* 清除一些不需要的html標記
*
* @param htmlStr
* 帶有復雜html標記的html語句
* @return 去除了不需要html標記的語句
*/
protected static String clearFormat(String htmlStr, String docImgPath) {
// 獲取body內容的正則
String bodyReg = "<BODY .*</BODY>";
Pattern bodyPattern = Pattern.compile(bodyReg);
Matcher bodyMatcher = bodyPattern.matcher(htmlStr);
if (bodyMatcher.find()) {
// 獲取BODY內容,並轉化BODY標簽為DIV
htmlStr = bodyMatcher.group().replaceFirst("<BODY", "<DIV")
.replaceAll("</BODY>", "</DIV>");
}
// 調整圖片地址
htmlStr = htmlStr.replaceAll("<IMG SRC=\"", "<IMG SRC=\"" + docImgPath
+ "/");
// 把<P></P>轉換成</div></div>保留樣式
// content = content.replaceAll("(<P)([^>]*>.*?)(<\\/P>)",
// "<div$2</div>");
// 把<P></P>轉換成</div></div>並刪除樣式
htmlStr = htmlStr.replaceAll("(<P)([^>]*)(>.*?)(<\\/P>)", "<p$3</p>");
// 刪除不需要的標簽
htmlStr = htmlStr
.replaceAll(
"<[/]?(font|FONT|span|SPAN|xml|XML|del|DEL|ins|INS|meta|META|[ovwxpOVWXP]:\\w+)[^>]*?>",
"");
// 刪除不需要的屬性
htmlStr = htmlStr
.replaceAll(
"<([^>]*)(?:lang|LANG|class|CLASS|style|STYLE|size|SIZE|face|FACE|[ovwxpOVWXP]:\\w+)=(?:'[^']*'|\"\"[^\"\"]*\"\"|[^>]+)([^>]*)>",
"<$1$2>");
return htmlStr;
}

}

㈣ 實現在微信中不藉助第三方閱讀器,直接在HTML5網頁上查看word/excel/ppt/pdf文檔

display: block;
-webkit-user-modify: read-write-plaintext-only
}
在css里邊找到.x-input-el
把下邊-webkit-user-modify: read-write-plaintext-only
這句添加上,就ok了。

㈤ H5頁面怎麼轉換為word文檔

打開這個來文檔,以桌面上隨便一個自word為例,就拿今天在軍事網上看到的文章為例吧,打這個文件打開;

打開這個word文件後,選擇office菜單下面的另存為菜單 ,如圖;

在」另存為「的下拉菜單中選擇最下面一個」其他格式「,如圖;
點擊進去之後,在文件格式網頁格式,然後再點保存就可以了;

㈥ 請問如何將html格式文件用word打開

HTML是網頁文件,可以用瀏覽器打開,所以你右鍵可以看到IE和SOUGOU,這都是瀏覽器,也可以用FRONPAGE打開,但是需要安裝有FRONPAGE才行。

閱讀全文

與html5打開word文件相關的資料

熱點內容
編程寫東西都寫得是什麼 瀏覽:35
蔚來怎麼推薦app 瀏覽:269
6s輸入密碼來使用siri 瀏覽:742
程序員黑客頭像酷 瀏覽:739
mvc接受上傳文件 瀏覽:365
程序員可以轉金融嗎 瀏覽:193
無需用戶名密碼的共享 瀏覽:775
一加怎麼和win10傳輸文件 瀏覽:425
大數據分析哪些行業 瀏覽:848
win10刪除自動更新文件在哪裡 瀏覽:581
cad打開一個文件要關閉另一文件 瀏覽:432
鋼鐵雄心4升級包 瀏覽:558
一加找不到恢復文件 瀏覽:960
遼寧高中查分數的app有哪些 瀏覽:790
考研復試編程題可以考什麼 瀏覽:118
微信老男人頭像圖片 瀏覽:588
貸款app有哪些東西 瀏覽:74
sim卡突然無網路連接怎麼辦 瀏覽:150
制度文件內容要簡潔 瀏覽:96
java正則表達式一個或多個空格 瀏覽:420

友情鏈接