cellHeader.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中
table.addCell(cellHeader);
cellHeader = new Cell();
Paragraph para1footer = new Paragraph();
para1footer.add(new Phrase("第"));
para1footer.add(new RtfPageNumber());//第几页
para1footer.add(new Phrase("页"));
para1footer.setAlignment(1);
cellHeader.add(para1footer);
cellHeader.setUseAscender(true);
cellHeader.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中
cellHeader.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中
table.addCell(cellHeader);
headerPara.add(table);
HeaderFooter header = new HeaderFooter(headerPara,false);
header.setAlignment(HeaderFooter.ALIGN_CENTER);
document.setHeader(header);
/**
* 设置页脚
*/
Paragraph footerPara1 = new Paragraph("公司地址: "+qybjCompany.getCompanyaddr(), contextFont);
Paragraph footerPara2 = new Paragraph("销售热线: "+qybjCompany.getMoblephone()+" "+qybjCompany.getLegalperson(), contextFont);
Paragraph footerPara3 = new Paragraph("此报价自报价之日起一个月内有效", titleFont);
Paragraph footerPara = new Paragraph();
footerPara.add(footerPara1);
footerPara.add(footerPara2);
footerPara.add(footerPara3);
footer.setAlignment(HeaderFooter.ALIGN_LEFT);
document.setFooter(footer);
// //在表格末尾添加图片
// Image png = Image.getInstance("c:/1.png");
//
// document.add(png);
document.close();
}catch (Exception e) {
// TODO: handle exception
log.error("导出word出现异常:", e);
}
return path;
}
/**
* TODO
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}