當前位置:首頁 » 編程語言 » 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-07-01 03:28:23 瀏覽:114
u盤插安卓手機上怎麼加密 發布:2025-07-01 03:09:19 瀏覽:90
php記住我 發布:2025-07-01 02:58:51 瀏覽:392
流媒體伺服器搭建php 發布:2025-07-01 02:54:24 瀏覽:371
我的世界伺服器地板方塊 發布:2025-07-01 02:41:35 瀏覽:564
魔域伺服器爆滿怎麼進 發布:2025-07-01 02:31:42 瀏覽:739
c語言統計字元出現的次數 發布:2025-07-01 02:27:24 瀏覽:242
江鈴福特主要有哪些車型以及配置 發布:2025-07-01 02:23:10 瀏覽:25
格式化資料庫 發布:2025-07-01 02:15:03 瀏覽:267
蘇州資料庫 發布:2025-07-01 02:09:25 瀏覽:617