使用iText导出Word,需要的Jar包有iText-2.1.7.jar,iTextAsian.jar,iText-rtf-2.1.7.jar
Expert expert=new Expert();
.......expert的一些属性省略
String fileName=new String(("专家信息-"+expert.getName()).getBytes("GBK"),"ISO-8859-1");//文件名称
response.setContentType("application/doc;charset=utf-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName+".doc");//文件标题,打开类型
com.lowagie.text.Rectangle rect=new com.lowagie.text.Rectangle(com.lowagie.text.PageSize.A4);//设置页面
rect.setBackgroundColor(Color.WHITE);//设置背景色
com.lowagie.text.Document document=new com.lowagie.text.Document(rect);//创建文件
document.setMargins(10, 20, 30, 40);//页边距
RtfWriter2 writer2=RtfWriter2.getInstance(document, response.getOutputStream());//创建书写器与document关联
// 文档属性
document.addTitle(&#