private static void createTable(XSLFSlide slide) {
XSLFTable table = slide.createTable();//创建3行13列的表格
table.setAnchor(new Rectangle2D.Double(10, 50, 0, 0));
for (int i = 0; i < 3; i++) {
//新建行
XSLFTableRow tableRow = table.addRow();
for (int j = 0; j < 13; j++) {
//新建单元格
XSLFTableCell tableCell = tableRow.addCell();
//设置单元格内容
XSLFTextParagraph p = tableCell.addNewTextParagraph();
XSLFTextRun run = p.addNewTextRun();
//run.setText(String.valueOf(j));
run.setText("test");
//设置单元格样式
tableCell.setFillColor(Color.getColor("0xdd7e6b"));
p.setTextAlign(TextAlign.CENTER);
tableCell.setVerticalAlignment(VerticalAlignment.MIDDLE);
tableCell.setBorderBottom(1);
tableCell.setBorderLeft(1);
tableCell.setBorderTop(1);
tableCell.setBorderRight(1);
tableCell.setBorderBottomColor(Color.BLACK);
tableCell.setBorderLeftColor(Color.BLACK);
tableCell.setBorderTopColor(Color.BLACK);
tableCell.setBorderRightColor(Color.BLACK);
}
tableRow.setHeight(30);
}
//合并单元格
table.mergeCells(0, 0, 4, 6);
table.mergeCells(0, 0, 7, 9);
table.mergeCells(0, 2, 0, 2);
table.mergeCells(0, 2, 3, 3);
table.mergeCells(1, 2, 4, 4);
table.mergeCells(1, 2, 5, 5);
table.mergeCells(1, 2, 6, 6);
table.mergeCells(1, 2, 7, 7);
table.mergeCells(1, 2, 8, 8);
table.mergeCells(1, 2, 9, 9);
table.mergeCells(0, 2, 10, 12);
}
我想使用以下代码获取ppt文件,但是当我使用Office 2007打开时,此文件为空,如果我删除了最后一个代码table.mergeCells(0, 2, 10, 12)
,则表示正确。
那么,你能告诉我如何解决它吗?