導航:首頁 > 文字圖片 > freemarkerword圖片

freemarkerword圖片

發布時間:2023-01-06 13:17:10

① 用FreeMarker方法java生成word文檔出現異常

應該是沒有成功生成,內部代碼里還包含了word無法識別的代碼塊,所以無法打開,你可以用記事本查看源代碼,freenarker轉換的word源代碼都是xml格式

② freemarker能生成word嗎

你說的是freemarker+flyingsaucer+itext用這個生成?
但是我已經用freemark生成了word了,也就是有一個模板了。如果用html生成pdf那就是要再寫一個模板。如果少數的幾個還可以,但是如果數量較多,比如20、30。就太麻煩了...

③ freemarker 導出word 文檔 怎麼

將要導出的Word另存為xml格式的文件,打開xml 在其中添加freemarker標簽,然後另存為outChairDoc.ftl文件.

第一步要加入Freemarker.jar包。

Servlet代碼如下:在outChairDoc.ftl放在包cn.skyclass.jiaowu.freemarker.template下

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

configuration = new Configuration();

configuration.setDefaultEncoding("utf-8");

try {

createDoc(response);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public void createDoc(HttpServletResponse response) throws Exception {

// 要填入模本的數據文件

Map dataMap = new HashMap();

dataMap.put("docTitle", "fdfdfdfdfdfdf用戶信息");

List<ChairInfo> list = new ArrayList<ChairInfo>();

ChairInfo chairInfo = new ChairInfo();

chairInfo.setChairTitle("dfdfd");

chairInfo.setTeacherName("tea");

chairInfo.setStartTime(new Date());

chairInfo.setPlace("dfdfd");

list.add(chairInfo);

dataMap.put("chairInfoList", list);

// 設置模本裝置方法和路徑,FreeMarker支持多種模板裝載方法。可以重servlet,classpath,資料庫裝載,

// 這里我們的模板是放在com.havenliu.document.template包下面

configuration.setClassForTemplateLoading(this.getClass(),

"/cn/skyclass/jiaowu/freemarker/template");

Template t = null;

try {

// test.ftl為要裝載的模板

t = configuration.getTemplate("outChairDoc.ftl");

t.setEncoding("utf-8");

} catch (IOException e) {

e.printStackTrace();

}

// 輸出文檔路徑及名稱

String fileName="講座列表.doc";

response.setContentType("application/msword");

response.addHeader("Content-Disposition", "attachment; filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));//可防止導出的文件亂碼

response.setCharacterEncoding("utf-8");

PrintWriter out = response.getWriter();

t.process(dataMap, out);

out.close();

}

④ java freemarker引擎 導出word文檔

要生成的數據,在java後台必須是用Map格式,這個你檢查一下有沒有問題。如果有list,也要放到map裡面去。

HashMap<String,Object>dataMap=newHashMap<String,Object>();
Configurationconf=newConfiguration();
Templatet=conf.getTemplate(fileName);
FiledocFile=newFile(filePath+"/"+docName);
out=newOutputStreamWriter(newFileOutputStream(docFile),"UTF-8");
t.process(dataMap,out);

⑤ java freemarker將多個word頁導出到一個word文件里

你的意思是以一個背景圖為主要模板·後面的2 3 4 5...頁都要用這個模板 是吧? 那簡單·word菜單里有個格式·在格式里有背景-水印-出來一個對話框·圖片水印·吧你要的背景放進去 ·就可以了·這樣後面的頁數都會是這個背景··如果你是插入圖片的那個方法··估計你每個頁面都要手動去設置了··望採納··

閱讀全文

與freemarkerword圖片相關的資料

熱點內容
圖片上的章如何摳 瀏覽:855
word壓縮圖片原理 瀏覽:370
word設置圖片格式無法點擊 瀏覽:317
肖戰花襯衣照片高清圖片 瀏覽:459
中國美女短發圖片 瀏覽:328
wps的word如何把圖片變為圓形 瀏覽:790
word文檔中圖片怎麼微調 瀏覽:393
ps如何把圖片從清晰到模糊過渡 瀏覽:491
肖戰圖片動漫 瀏覽:926
裸體美女陰部圖片 瀏覽:153
男生偽裝成女生後的圖片 瀏覽:912
手機沒裝卡圖片怎麼拿出來 瀏覽:660
夏日甜心的女孩圖片 瀏覽:355
適合男胖子的短發發型圖片 瀏覽:843
模糊圖片動漫 瀏覽:614
熊出沒土撥鼠可愛圖片 瀏覽:572
小女生裙子圖片 瀏覽:766
簡單民族服裝圖片大全 瀏覽:86
如何把電腦里的圖片保存到蘋果手機 瀏覽:814
國外女孩頭像圖片真人 瀏覽:395