Posted on 2011-02-25 11:40
非洲小白脸 阅读(1078)
评论(2) 编辑 收藏 所属分类:
excel word + macro
try {
response.reset();
response.setContentType("txt/rtf; charset=GBK");
String fileName = "XXXX.rtf";
this.pageWrapper.response.addHeader("Content-Disposition", "attachment; filename=" + fileName);
//生成word
String rtfSource = ("D://wwww.rtf") ;
RTFTemplateBuilder builder = RTFTemplateBuilder.newRTFTemplateBuilder()
RTFTemplate rtfTemplate = builder.newRTFTemplate();
rtfTemplate.setTemplate(new File(rtfSource));
// 对于模板中的变量赋值
rtfTemplate.put("time1","变量1");
PrintWriter writer = response.getWriter();
rtfTemplate.merge(writer);
writer.flush();
writer.close();
} catch (Exception e) {
e.printStackTrace();
throw e;
}
模板文件:
时间1
|
$time1
|
时间2
|
|
时间3
|
$time3
|
时间4
|
|
时间5
|
$time5
|
时间6
|
|