javahtml轉word
① java怎樣通過網址將頁面轉為word,不是將靜態頁面轉word
兩種方式:
1、純Java,用POI來做
2、用JNA調用word介面,根據office api來做
第一種呢對於java開發來說相對簡單,但是需要學POI,而且估計有些格式控制不好。第二種要學習JNA,而且需要邊做變差word的office api。
② JAVA中,html轉換為word的工具包有哪些
簡單,用OpenOffice的soffice進行轉換。html轉word的話,圖片是個問題,應該有解決方案,例如使用odt做中間產物
③ java中html轉word出現的問題
兩種方式:
1、純Java,用POI來做
2、用JNA調用word介面,根據office api來做
第一種呢對於java開發來說相對回簡單,但是需答要學POI,而且估計有些格式控制不好。第二種要學習JNA,而且需要邊做變差word的office api。
④ java 如何將html轉換為word
兩種方式:
1、純Java,用POI來做
2、用JNA調用word介面,根據office api來做
第一種呢對於java開發來說相對簡單,但是需要內學POI,而且估計有些容格式控制不好。第二種要學習JNA,而且需要邊做變差word的office api。
⑤ java 如何將html(包含表格,圖片)轉換為word
你用IE瀏覽器打開你的HTML文件,然後點擊菜單欄 文件→使用 Microsoft Office Word 編輯,之後系統會自專動打開 Word 並顯示HTML文件的內容,這屬是保存即可。
如果找不到「使用 Microsoft Office Word 編輯」的話,點擊菜單欄 工具→Internet 選項→程序→ HTML 編輯器 → Microsoft Office Word → 確定。
⑥ 請問java中用jacob將html轉word中文亂碼怎麼解決
有中文亂碼一般都是字元編碼的問題,那你就是設置一下字元編碼看看能不能解決這個問題。
⑦ java怎麼由html生成word,保留html樣式
@RequestMapping("download")
public void exportWord( HttpServletRequest request, HttpServletResponse response)
throws Exception {
User user = AppContext.getLoginUser();
Student student = studentSvc.findByUserId(user.getId());
try {
//word內容
String content="<html><body></body></html>";
byte b[] = content.getBytes("utf-8"); //這里是必須要設置編碼的,不然導出中文就會亂碼。
ByteArrayInputStream s = new ByteArrayInputStream(b);//將位元組數組包裝到流中
/*
* 關鍵地方
* 生成word格式
*/
POIFSFileSystem poifs = new POIFSFileSystem();
DirectoryEntry directory = poifs.getRoot();
DocumentEntry documentEntry = directory.createDocument("WordDocument", s);
//輸出文件
String fileName="實習考核鑒定表";
request.setCharacterEncoding("utf-8");
response.setContentType("application/msword");//導出word格式
response.addHeader("Content-Disposition", "attachment;filename=" +
new String( (fileName + ".doc").getBytes(),
"iso-8859-1"));
OutputStream ostream = response.getOutputStream();
poifs.writeFilesystem(ostream);
s.close();
ostream.close();
}catch(Exception e){
AppUtils.logError("導出出錯:%s", e.getMessage());
}
}
⑧ 請教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
如果你只是想要不依賴網路的存儲圖片的話,可以試試把圖片轉base64