答案 0 :(得分:0)
假设MainDocumentPart mdp:
int widthTwips = 4788;
Tbl mainTable = TblFactory.createTable(2, 2, widthTwips);
List<Object> rows = mainTable.getContent();
Tr row = (Tr) rows.get(0);
List<Object> cells = row.getContent();
Tc cell = (Tc) cells.get(0);
Tbl nestedTable = TblFactory.createTable(1, 2, 2000);
// You'll get an error in Word if you don't have an empty <p/> after the nested table.
// Since TblFactory.createTable automatically added an empty <p>, add the table before it
cell.getContent().add(0, nestedTable);
mdp.getContent().add(mainTable);
请参阅代码段中的解释性注释。