-
word table
table分两种
word中的table对应org.anyline.office.docx.entity.Wtable
与html中的table对就org.anyline.office.docx.entity.html.Table
word中的Table需要从Document中提取
根据书签获取word中的表格,需要在表格中添加一个书签,在任何一个单元格添加都可以。
WDocument doc = new WDocument("file path");
Wtable table = doc.getTable("mk_table");
也可以获取所有table
List<Wtable> tables = doc.tables(); -
根据数据集生成tr插入table
根据数据集生成tr插入table,如果是集合则会插入多行,否则插入一行 -
根据数据集生成tr插入table的指定位置
table.insert(index, list, "ID","NAME"); index表示需要插入的下标位置 -
table获取行或列
Wtr tr = table.getTr(rows); Wtc tc = table.getTc(rows, cols); -
设置单元格内容(含css样式)
设置单元格内容(含css样式) -
在指定位置添加行列,默认复制上一行(列)样式
所有行添加一列,并复制前一列的样式 table.addColumns(1); 从下标1位置开始添加10行,并复制上一行的样式 table.addRows(1,10); -
设置单元格背景色
table.setBackgroundColor(rows, cols, "red"); 支持css颜色值 -
设置默认边框
table.setBorder(rows, cols); 边框线条以4为一个单位 table.setBorder(rows, cols, 4, "red", "single"); -
设置所有单元格边框
设置所有单元格边框 边框有top bootom left right tl2br tr2bl insideH insideV table.setTcBorder(); table.setTl2brBorder(rows, cols); table.removeBorder(rows, cols); table.removeLeftBorder(rows, cols); -
设置高度宽度
高度表示整行高度 宽度表示整列宽度 table.setHeight(rwos, '100px'); table.setWidth(cols, '100px'); -
设置对齐方式
水平对齐 table.setAlign(rows, cols, "right"); 垂直对齐 table.stVerticalAlign(rows, cols, "top");