use of org.docx4j.wml.Tr in project docx4j-template by vindell.
the class DocxElementWmlRender method newTable.
public Tbl newTable(int row, int cell) {
// 创建表格对象
Tbl table = factory.createTbl();
for (int i = 0; i < row; i++) {
Tr tableRow = factory.createTr();
for (int j = 0; j < cell; j++) {
newCell(tableRow, "");
}
table.getContent().add(tableRow);
}
return table;
}
use of org.docx4j.wml.Tr in project docx4j-template by vindell.
the class DocxElementWmlRender method newRow.
public Tr newRow(Tbl table, int row) {
Tr tbRow = factory.createTr();
table.getContent().set(row, tbRow);
return tbRow;
}
use of org.docx4j.wml.Tr in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method getTblContentList.
/**
* @Description: 获取表格内容
*/
public List<String> getTblContentList(Tbl tbl) throws Exception {
List<String> resultList = new ArrayList<String>();
List<Tr> trList = getTblAllTr(tbl);
for (Tr tr : trList) {
StringBuffer sb = new StringBuffer();
List<Tc> tcList = getTrAllCell(tr);
for (Tc tc : tcList) {
sb.append(getElementContent(tc) + ",");
}
resultList.add(sb.toString());
}
return resultList;
}
use of org.docx4j.wml.Tr in project docx4j-template by vindell.
the class SettingColumnWidthForTable method main.
/**
* 创建一个带边框的表格并添加一行. 然后添加两个带内容的单元格并给定宽度.
*/
public static void main(String[] args) throws Docx4JException {
wordMLPackage = WordprocessingMLPackage.createPackage();
factory = Context.getWmlObjectFactory();
Tbl table = factory.createTbl();
addBorders(table);
Tr tr = factory.createTr();
addTableCellWithWidth(tr, "Field 1", 2500);
addTableCellWithWidth(tr, "Field 2", 0);
table.getContent().add(tr);
wordMLPackage.getMainDocumentPart().addObject(table);
wordMLPackage.save(new java.io.File("src/main/HelloWord133.docx"));
}
Aggregations