html轉wordjava
❶ 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 → 確定。