InputStream fileStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("dosc.doc");
if (fileStream == null) {
return;
}
Document document = new Document();
DocumentBuilder builder = new DocumentBuilder(document);
//单元格水平居中对齐
builder.getCellFormat().setVerticalAlignment(CellVerticalAlignment.CENTER);
//段落居中对齐
builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
//文本颜色
builder.getFont().setColor(Color.red);
builder.getFont().setSize(15D);
builder.writeln("阅办单");
builder.getFont().setSize(8D);
builder.getFont().setColor(Color.black);
//段落左对齐 builder.getParagraphFormat().setAlignment(ParagraphAlignment.LEFT);
Table table =builder.startTable();
RowFormat rowf = builder.getRowFormat();
rowf.setHeight(40) ;
//表头
builder.insertCell();
builder.getCellFormat().setWidth(40) ;
builder.write("序号111");
builder.insertCell();
builder.getCellFormat().setWidth(4) ;
builder.write("考试");
builder.insertCell();
builder.write("考试时长");
builder.insertCell();
builder.write("成绩");
builder.insertCell();
builder.write("排名");
builder.insertCell();
builder.write("考试类型");
builder.endRow();
builder.endTable();
table.setBorders(LineStyle.SINGLE, 0.5, Color.red);
document.save("D:a.doc", SaveFormat.DOC);