日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

jsoup填充内容然后html转word

發布時間:2024/3/12 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 jsoup填充内容然后html转word 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

模板

<!DOCTYPE html> <html lang="en" xmlns:v='urn:schemas-microsoft-com:vml'xmlns:o='urn:schemas-microsoft-com:office:office'xmlns:w='urn:schemas-microsoft-com:office:word'xmlns:m='http://schemas.microsoft.com/office/2004/12/omml'xmlns='http://www.w3.org/TR/REC-html40' xmlns='http://www.w3.org/1999/xhtml'> <head> <!--[if gte mso 9]><xml><w:WordDocument><w:View>Print</w:View><w:TrackMoves>false</w:TrackMoves><w:TrackFormatting/><w:ValidateAgainstSchemas/><w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid><w:IgnoreMixedContent>false</w:IgnoreMixedContent><w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText><w:DoNotPromoteQF/><w:LidThemeOther>EN-US</w:LidThemeOther><w:LidThemeAsian>ZH-CN</w:LidThemeAsian><w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript><w:Compatibility><w:BreakWrappedTables/><w:SnapToGridInCell/><w:WrapTextWithPunct/><w:UseAsianBreakRules/><w:DontGrowAutofit/><w:SplitPgBreakAndParaMark/><w:DontVertAlignCellWithSp/><w:DontBreakConstrainedForcedTables/><w:DontVertAlignInTxbx/><w:Word11KerningPairs/><w:CachedColBalance/><w:UseFELayout/></w:Compatibility><w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel><m:mathPr><m:mathFont m:val="Cambria Math"/><m:brkBin m:val="before"/><m:brkBinSub m:val="--"/><m:smallFrac m:val="off"/><m:dispDef/><m:lMargin m:val="0"/> <m:rMargin m:val="0"/><m:defJc m:val="centerGroup"/><m:wrapIndent m:val="1440"/><m:intLim m:val="subSup"/><m:naryLim m:val="undOvr"/></m:mathPr></w:WordDocument></xml><![endif]--> <meta charset="UTF-8"> <title>Title</title> </head> <body> </body> </html>


<dependency> <groupId>org.jsoup</groupId> <artifactId>jsoup</artifactId> <version>1.10.3</version> </dependency> /* * content 數據 * path 保存路徑 * fileModPath 模板文件路徑* */ public static boolean htmlToWord(String content,String fileName,String path,String fileModPath){try {//將數據寫入模板html的body中 // InputStream html=UeditorToDoc.class.getResourceAsStream(fileModPath); InputStream html=UeditorToDoc.class.getClassLoader().getResourceAsStream(fileModPath);//需要一個html模板 String conte=getContent(html); Document document= Jsoup.parse(conte); Element body=document.body(); body.html(content); /* 生成doc */ File file=new File(path+fileName+".html"); FileWriter fileWriter=new FileWriter(file); String htmls=new String(document.html().getBytes("UTF-8"),"UTF-8"); fileWriter.write(htmls); fileWriter.close(); html.close(); File file1=new File(path+fileName+".doc"); if(file.renameTo(file1)){return true; }else {return false; }} catch (Exception e) {e.printStackTrace(); return false; }}





總結

以上是生活随笔為你收集整理的jsoup填充内容然后html转word的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。