1、填充Word表格内容/**
* 循环填充表格内容
* @param xwpfDocument
* @param params
* @param tableIndex
* @throws Exception
*/
private void insertValueToTable(XWPFDocument xwpfDocument, List> params, int tableIndex) throws Exception {
try {
List tableList = xwpfDocument.getTables();
if (tableList.size() <= tableIndex) {
throw new Exception("tableIndex对应的表格不存在");
}
XWPFTable table = tableList.get(tableIndex);
List rows = table.getRows();
if (rows.size() < 2) {
throw new Exception("tableIndex对应表格应该为2行");
}
//模板的那一行
XWPFTableRow tmpRow = rows.get(1);
List tmpCells = null;
List cells = null;
XWPFTableCell tmpCell = null;
tmpCells = tmpRow.getTableCells();
String cellText = null;
String cellTextKey = null;
Map totalMap = null;
for (int i = 0, len = params.size(); i < len; i++) {
Map map = params.get(i);
// 创建新的一行
XWPFTableRow row = table.createRow();
// 获取模板的行高 设置为新一行的行高
row.setHeight(tmpRow.getHeight());
cells = row.getTableCells();
for (int k = 0, klen = cells.size(); k < klen; k++) {
tmpCell = tmpCells.get(k);
XWPFTableCell cell = cells.get(k);
cellText = tmpCell.getText();
if (StringUtils.isNotBlank(cellText)) {
//转换为mapkey对应的字段
<