當前位置:首頁 » 編程語言 » html轉wordjava

html轉wordjava

發布時間: 2023-05-31 10:07:27

java 怎樣將HTML文件轉化成完全兼容word2003格式的文件

如扒模握果你是將HTML文件轉換成word文件的話,應春慶該可以直接用文件流將html文件的後綴名改為.doc即可,因為word本碼喚來就能打開HTML。

❷ 用java把html轉成word文檔,html中的圖片怎麼辦

圖片需要忽略,然後再插入對應位置

❸ 請問java中用jacob將html轉word中文亂碼怎麼解決

有中文亂碼一般都是字元編碼的問題,那你就是設置一下字元編碼看看能不能解決這個問題。

❹ 請教java html導出word如何實現

java將html導出word不用忘記尺粗和<html></html>這對標簽
//換頁
<span style='font-size:16px;line-height:150%;font-family:"Times New Roman";
mso-fareast-font-family:宋體;mso-font-kerning:1px;mso-ansi-language:EN-US;
mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA'><br clear=all style='mso-special-character:page-break;page-break-before:always'>
</span>

//換行
<陵盯p style='line-height:150%'><span style='font-size:16px;line-height:150%'><o:p> </o:p></span></p>

查看的話 打開word 視圖——頁面 就能看出看出效果

[java] view plain print?
ArrayList records = form.getRecords();//獲取資料庫數據
if(null!=records&&0!=records.size()){
//html拼接出word內容
String content="<html>";
for (int i = 0; i < records.size(); i++) {
Record record =(Record) records.get(i);
//從資料庫中獲得數據,將oracle中的clob數據類型轉換成string類型
Method method = record.get("CONTENT").getClass().getMethod("getVendorObj",new Class[]{});
CLOB clob = (CLOB)method.invoke(record.get("CONTENT"));
String cx = clob.getSubString((long) 1, (int) clob.length());
String title= (String) record.get("TITLE");
//html拼接出word內容
content+="<div style=\"text-align: center\"><span style=\"font-size: 24px\"><span style=\"font-family: 黑體\">"+title+"<br /> <br /> </span></span></div>";
content+="<div style=\"text-align: left\"><span >"+cx+"<br /> <br /> </span></span></div>";
//插入分頁符
content+="<span lang=EN-US style='font-size:16px;line-height:150%;mso-fareast-font-family:宋體;mso-font-kerning:1px;mso-ansi-language:EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA'><br clear=all style='page-break-before:always'></span>";
content+="<p class=MsoNormal style='line-height:150%'凳笑><span lang=EN-US style='font-size:16px;line-height:150%'><o:p> </o:p></span></p>";

}
content += "</html>";
byte b[] = content.getBytes();
ByteArrayInputStream s = new ByteArrayInputStream(b);
POIFSFileSystem poifs = new POIFSFileSystem();
DirectoryEntry directory = poifs.getRoot();
DocumentEntry documentEntry = directory.createDocument("WordDocument", s);
//輸出文件
String name="導出知識";
response.reset();
response.setHeader("Content-Disposition",
"attachment;filename=" +
new String( (name + ".doc").getBytes(),
"iso-8859-1"));
response.setContentType("application/msword");
OutputStream ostream = response.getOutputStream();
//輸出文件的話,new一個文件流
//FileOutputStream ostream = new FileOutputStream(path+ fileName);
poifs.writeFilesystem(ostream);
ostream.flush();
ostream.close();
s.close();

❺ java 如何將html(包含表格,圖片)轉換為word

你用IE瀏覽器打開你的HTML文件,然後點擊菜單欄 文件→使用 Microsoft Office Word 編輯,之後系統會自動打開 Word 並顯示HTML文件的內容,這是保存即可。

如果找不到「使用 Microsoft Office Word 編輯」的話,點擊菜單欄 工具→Internet 選項→程序→ HTML 編輯器 → Microsoft Office Word → 確定。

熱點內容
內置存儲卡可以拆嗎 發布:2025-05-18 04:16:35 瀏覽:335
編譯原理課時設置 發布:2025-05-18 04:13:28 瀏覽:378
linux中進入ip地址伺服器 發布:2025-05-18 04:11:21 瀏覽:612
java用什麼軟體寫 發布:2025-05-18 03:56:19 瀏覽:31
linux配置vim編譯c 發布:2025-05-18 03:55:07 瀏覽:107
砸百鬼腳本 發布:2025-05-18 03:53:34 瀏覽:942
安卓手機如何拍視頻和蘋果一樣 發布:2025-05-18 03:40:47 瀏覽:739
為什麼安卓手機連不上蘋果7熱點 發布:2025-05-18 03:40:13 瀏覽:802
網卡訪問 發布:2025-05-18 03:35:04 瀏覽:510
接收和發送伺服器地址 發布:2025-05-18 03:33:48 瀏覽:371