Browse Source

选址影响因子表格对齐

gushoubang 1 year ago
parent
commit
cbc5b2e257

+ 9 - 0
onemap-modules/onemap-analyse/src/main/java/com/onemap/analyse/utils/NpoiHelper.java

@@ -147,6 +147,15 @@ public class NpoiHelper {
             for (int col = 0; col < tableTitle.size(); col++) {
                 TableTitle cobj = tableTitle.get(col);
                 XWPFTableCell cell = mr.getCell(col);
+
+                // 设置内容单元格的宽度
+                CTTc ctTc = cell.getCTTc();
+                CTTcPr ctTcPr = ctTc.isSetTcPr() ? ctTc.getTcPr() : ctTc.addNewTcPr();
+                CTTblWidth ctTblWidth = ctTcPr.addNewTcW();
+                int width = tableTitle.get(col).getWidth();
+                ctTblWidth.setW(BigInteger.valueOf(width));
+                ctTblWidth.setType(STTblWidth.DXA);
+
                 Object o = datas.get(row).get(cobj.key);
                 String text = o == null ? "" : o.toString();
                 if (cobj.xsw > -1) {