最近打算做日周月的质量分析报告,以便于发送给相应负责人查看质量现状。希望是可以生成pdf,并发送邮件的形式。
此处采用itext来进行实现,demo代码中,table定义以及表头如下代码所示:
[img]http://dl2.iteye.com/upload/attachment/0096/1236/92f46fa5-7ea2-3210-8e2e-efbe940ed10a.png[/img]
此处采用itext来进行实现,demo代码中,table定义以及表头如下代码所示:
public static Table getInitTable() throws DocumentException {
Table t = new Table(10, 2);
int width[] = { 50, 50,20,40, 80, 50, 50, 50, 50, 60 };
t.setWidths(width);
t.setWidth(100); // 占页面宽度 %
t.setPadding(1);
t.setSpacing(0);
t.setBorderWidth(1);
Cell c1 = new Cell(new Phrase("应用", PdfUtils.GRAYFONT_CHINESE));
c1.setRowspan(2);
setAlignCenter(c1);
t.addCell(c1);
c1 = new Cell(new Phrase("指标", PdfUtils.GRAYFONT_CHINESE));
c1.setColspan(3);
setAlignCenter(c1);
t.addCell(c1);
c1 = new Cell(new Phrase("本期数据", PdfUtils.GRAYFONT_CHINESE));
c1.setRowspan(2);
setAlignCenter(c1);
t.addCell(c1);
c1 = new Cell(new Phrase("上期环比", PdfUtils.GRAYFONT_CHINESE));
c1.setRowspan(2);
setAlignCenter(c1);
t.addCell(c1);
c1 = new Cell(new Phrase("同期对比", PdfUtils.GRAYFONT_CHINESE));
c1.setRowspan(2);
setAlignCenter(c1);
t.addCell(c1);
c1 = new Cell(new Phrase("均值对比", PdfUtils.GRAYFONT_CHINESE));
c1.setRowspan(2);
setAlignCenter(c1);
t.addCell(c1);
c1 = new Cell(new Phrase("告警次数", PdfUtils.GRAYFONT_CHINESE));
c1.setRowspan(2);
setAlignCenter(c1);
t.addCell(c1);
c1 = new Cell(new Phrase("告警时长(分钟)", PdfUtils.GRAYFONT_CHINESE));
c1.setRowspan(2);
setAlignCenter(c1);
t.addCell(c1);
c1 = new Cell(new Phrase("字段", PdfUtils.GRAYFONT_CHINESE));
setAlignCenter(c1);
t.addCell(c1);
c1 = new Cell(new Phrase("统计方式", PdfUtils.GRAYFONT_CHINESE));
c1.setColspan(2);
setAlignCenter(c1);
t.addCell(c1);
return t;
}
[img]http://dl2.iteye.com/upload/attachment/0096/1236/92f46fa5-7ea2-3210-8e2e-efbe940ed10a.png[/img]