POI在指定位置插入,新建表格
如题:以下是代码部分
try {
OPCPackage pack = POIXMLDocument.openPackage("d:/newTestCopyTable.docx");
CustomXWPFDocument doc = new CustomXWPFDocument(pack);
List<XWPFTable> tableList = doc.getTables();
for (int i = 0; i < tableList.size(); i++) {
XWPFTable table = tableList.get(i);
XWPFTable newTable = doc.createTable();
doc.insertTable(i, newTable);//----此行不能执行,报错
}
}catch(Exception e){
e.printStackTrace();
}