月报导出--设置单元格边距
This commit is contained in:
+80
-26
@@ -25,6 +25,7 @@ import org.apache.poi.xwpf.usermodel.XWPFRun;
|
|||||||
import org.apache.poi.xwpf.usermodel.XWPFStyle;
|
import org.apache.poi.xwpf.usermodel.XWPFStyle;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFStyles;
|
import org.apache.poi.xwpf.usermodel.XWPFStyles;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFTable;
|
import org.apache.poi.xwpf.usermodel.XWPFTable;
|
||||||
|
import org.apache.poi.xwpf.usermodel.XWPFTableCell;
|
||||||
import org.apache.xmlbeans.impl.xb.xmlschema.SpaceAttribute;
|
import org.apache.xmlbeans.impl.xb.xmlschema.SpaceAttribute;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFldChar;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFldChar;
|
||||||
@@ -39,6 +40,9 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle;
|
|||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblLayoutType;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblLayoutType;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
|
||||||
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc;
|
||||||
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcMar;
|
||||||
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJc;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJc;
|
||||||
@@ -743,18 +747,30 @@ public class WordUtil {
|
|||||||
CTTblWidth ctTblWidth0 = table.getRow(i).getCell(0).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth0 = table.getRow(i).getCell(0).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth0.setType(STTblWidth.DXA);
|
ctTblWidth0.setType(STTblWidth.DXA);
|
||||||
ctTblWidth0.setW(BigInteger.valueOf(703));
|
ctTblWidth0.setW(BigInteger.valueOf(703));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell0 = table.getRow(i).getCell(0);
|
||||||
|
cellPadding(cell0);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth1 = table.getRow(i).getCell(1).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth1 = table.getRow(i).getCell(1).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth1.setType(STTblWidth.DXA);
|
ctTblWidth1.setType(STTblWidth.DXA);
|
||||||
ctTblWidth1.setW(BigInteger.valueOf(1984));
|
ctTblWidth1.setW(BigInteger.valueOf(1984));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell1 = table.getRow(i).getCell(1);
|
||||||
|
cellPadding(cell1);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth2 = table.getRow(i).getCell(2).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth2 = table.getRow(i).getCell(2).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth2.setType(STTblWidth.DXA);
|
ctTblWidth2.setType(STTblWidth.DXA);
|
||||||
ctTblWidth2.setW(BigInteger.valueOf(3543));
|
ctTblWidth2.setW(BigInteger.valueOf(3543));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell2 = table.getRow(i).getCell(2);
|
||||||
|
cellPadding(cell2);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth3 = table.getRow(i).getCell(3).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth3 = table.getRow(i).getCell(3).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth3.setType(STTblWidth.DXA);
|
ctTblWidth3.setType(STTblWidth.DXA);
|
||||||
ctTblWidth3.setW(BigInteger.valueOf(2081));
|
ctTblWidth3.setW(BigInteger.valueOf(2081));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell3 = table.getRow(i).getCell(3);
|
||||||
|
cellPadding(cell3);
|
||||||
|
|
||||||
table.getRow(i).getCell(0).setText(String.valueOf(i));
|
table.getRow(i).getCell(0).setText(String.valueOf(i));
|
||||||
table.getRow(i).getCell(1).setText(planNumber);
|
table.getRow(i).getCell(1).setText(planNumber);
|
||||||
@@ -769,22 +785,37 @@ public class WordUtil {
|
|||||||
CTTblWidth ctTblWidth0 = table.getRow(i).getCell(0).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth0 = table.getRow(i).getCell(0).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth0.setType(STTblWidth.DXA);
|
ctTblWidth0.setType(STTblWidth.DXA);
|
||||||
ctTblWidth0.setW(BigInteger.valueOf(708));
|
ctTblWidth0.setW(BigInteger.valueOf(708));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell0 = table.getRow(i).getCell(0);
|
||||||
|
cellPadding(cell0);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth1 = table.getRow(i).getCell(1).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth1 = table.getRow(i).getCell(1).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth1.setType(STTblWidth.DXA);
|
ctTblWidth1.setType(STTblWidth.DXA);
|
||||||
ctTblWidth1.setW(BigInteger.valueOf(1990));
|
ctTblWidth1.setW(BigInteger.valueOf(1990));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell1 = table.getRow(i).getCell(1);
|
||||||
|
cellPadding(cell1);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth2 = table.getRow(i).getCell(2).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth2 = table.getRow(i).getCell(2).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth2.setType(STTblWidth.DXA);
|
ctTblWidth2.setType(STTblWidth.DXA);
|
||||||
ctTblWidth2.setW(BigInteger.valueOf(3124));
|
ctTblWidth2.setW(BigInteger.valueOf(3124));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell2 = table.getRow(i).getCell(2);
|
||||||
|
cellPadding(cell2);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth3 = table.getRow(i).getCell(3).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth3 = table.getRow(i).getCell(3).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth3.setType(STTblWidth.DXA);
|
ctTblWidth3.setType(STTblWidth.DXA);
|
||||||
ctTblWidth3.setW(BigInteger.valueOf(1247));
|
ctTblWidth3.setW(BigInteger.valueOf(1247));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell3 = table.getRow(i).getCell(3);
|
||||||
|
cellPadding(cell3);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth4 = table.getRow(i).getCell(4).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth4 = table.getRow(i).getCell(4).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth4.setType(STTblWidth.DXA);
|
ctTblWidth4.setType(STTblWidth.DXA);
|
||||||
ctTblWidth4.setW(BigInteger.valueOf(1247));
|
ctTblWidth4.setW(BigInteger.valueOf(1247));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell4 = table.getRow(i).getCell(4);
|
||||||
|
cellPadding(cell4);
|
||||||
|
|
||||||
table.getRow(i).getCell(0).setText(String.valueOf(i));
|
table.getRow(i).getCell(0).setText(String.valueOf(i));
|
||||||
table.getRow(i).getCell(1).setText(planNumber);
|
table.getRow(i).getCell(1).setText(planNumber);
|
||||||
@@ -800,22 +831,37 @@ public class WordUtil {
|
|||||||
CTTblWidth ctTblWidth0 = table.getRow(0).getCell(0).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth0 = table.getRow(0).getCell(0).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth0.setType(STTblWidth.DXA);
|
ctTblWidth0.setType(STTblWidth.DXA);
|
||||||
ctTblWidth0.setW(BigInteger.valueOf(708));
|
ctTblWidth0.setW(BigInteger.valueOf(708));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell0 = table.getRow(0).getCell(0);
|
||||||
|
cellPadding(cell0);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth1 = table.getRow(0).getCell(1).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth1 = table.getRow(0).getCell(1).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth1.setType(STTblWidth.DXA);
|
ctTblWidth1.setType(STTblWidth.DXA);
|
||||||
ctTblWidth1.setW(BigInteger.valueOf(1990));
|
ctTblWidth1.setW(BigInteger.valueOf(1990));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell1 = table.getRow(0).getCell(1);
|
||||||
|
cellPadding(cell1);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth2 = table.getRow(0).getCell(2).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth2 = table.getRow(0).getCell(2).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth2.setType(STTblWidth.DXA);
|
ctTblWidth2.setType(STTblWidth.DXA);
|
||||||
ctTblWidth2.setW(BigInteger.valueOf(3124));
|
ctTblWidth2.setW(BigInteger.valueOf(3124));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell2 = table.getRow(0).getCell(2);
|
||||||
|
cellPadding(cell2);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth3 = table.getRow(0).getCell(3).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth3 = table.getRow(0).getCell(3).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth3.setType(STTblWidth.DXA);
|
ctTblWidth3.setType(STTblWidth.DXA);
|
||||||
ctTblWidth3.setW(BigInteger.valueOf(1247));
|
ctTblWidth3.setW(BigInteger.valueOf(1247));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell3 = table.getRow(0).getCell(3);
|
||||||
|
cellPadding(cell3);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth4 = table.getRow(0).getCell(4).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth4 = table.getRow(0).getCell(4).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth4.setType(STTblWidth.DXA);
|
ctTblWidth4.setType(STTblWidth.DXA);
|
||||||
ctTblWidth4.setW(BigInteger.valueOf(1247));
|
ctTblWidth4.setW(BigInteger.valueOf(1247));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell4 = table.getRow(0).getCell(4);
|
||||||
|
cellPadding(cell4);
|
||||||
|
|
||||||
table.getRow(0).getCell(0).setText(number);
|
table.getRow(0).getCell(0).setText(number);
|
||||||
table.getRow(0).getCell(1).setText(planNumber);
|
table.getRow(0).getCell(1).setText(planNumber);
|
||||||
@@ -831,18 +877,30 @@ public class WordUtil {
|
|||||||
CTTblWidth ctTblWidth0 = table.getRow(0).getCell(0).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth0 = table.getRow(0).getCell(0).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth0.setType(STTblWidth.DXA);
|
ctTblWidth0.setType(STTblWidth.DXA);
|
||||||
ctTblWidth0.setW(BigInteger.valueOf(703));
|
ctTblWidth0.setW(BigInteger.valueOf(703));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell0 = table.getRow(0).getCell(0);
|
||||||
|
cellPadding(cell0);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth1 = table.getRow(0).getCell(1).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth1 = table.getRow(0).getCell(1).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth1.setType(STTblWidth.DXA);
|
ctTblWidth1.setType(STTblWidth.DXA);
|
||||||
ctTblWidth1.setW(BigInteger.valueOf(1984));
|
ctTblWidth1.setW(BigInteger.valueOf(1984));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell1 = table.getRow(0).getCell(1);
|
||||||
|
cellPadding(cell1);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth2 = table.getRow(0).getCell(2).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth2 = table.getRow(0).getCell(2).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth2.setType(STTblWidth.DXA);
|
ctTblWidth2.setType(STTblWidth.DXA);
|
||||||
ctTblWidth2.setW(BigInteger.valueOf(3543));
|
ctTblWidth2.setW(BigInteger.valueOf(3543));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell2 = table.getRow(0).getCell(2);
|
||||||
|
cellPadding(cell2);
|
||||||
|
|
||||||
CTTblWidth ctTblWidth3 = table.getRow(0).getCell(3).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth3 = table.getRow(0).getCell(3).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth3.setType(STTblWidth.DXA);
|
ctTblWidth3.setType(STTblWidth.DXA);
|
||||||
ctTblWidth3.setW(BigInteger.valueOf(2081));
|
ctTblWidth3.setW(BigInteger.valueOf(2081));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell3 = table.getRow(0).getCell(3);
|
||||||
|
cellPadding(cell3);
|
||||||
|
|
||||||
table.getRow(0).getCell(0).setText(number);
|
table.getRow(0).getCell(0).setText(number);
|
||||||
table.getRow(0).getCell(1).setText(planNumber);
|
table.getRow(0).getCell(1).setText(planNumber);
|
||||||
@@ -881,9 +939,15 @@ public class WordUtil {
|
|||||||
CTTblWidth ctTblWidth0 = table.getRow(number).getCell(0).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth0 = table.getRow(number).getCell(0).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth0.setType(STTblWidth.DXA);
|
ctTblWidth0.setType(STTblWidth.DXA);
|
||||||
ctTblWidth0.setW(BigInteger.valueOf(2296));//宽度通过计算得来-->列表实际宽度除以2.54再乘以1440
|
ctTblWidth0.setW(BigInteger.valueOf(2296));//宽度通过计算得来-->列表实际宽度除以2.54再乘以1440
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell0 = table.getRow(number).getCell(0);
|
||||||
|
cellPadding(cell0);
|
||||||
CTTblWidth ctTblWidth1 = table.getRow(number).getCell(1).getCTTc().addNewTcPr().addNewTcW();
|
CTTblWidth ctTblWidth1 = table.getRow(number).getCell(1).getCTTc().addNewTcPr().addNewTcW();
|
||||||
ctTblWidth1.setType(STTblWidth.DXA);
|
ctTblWidth1.setType(STTblWidth.DXA);
|
||||||
ctTblWidth1.setW(BigInteger.valueOf(6015));
|
ctTblWidth1.setW(BigInteger.valueOf(6015));
|
||||||
|
//设置单元格边距
|
||||||
|
XWPFTableCell cell1 = table.getRow(number).getCell(1);
|
||||||
|
cellPadding(cell1);
|
||||||
|
|
||||||
// XWPFParagraph para = table.getRow(number).getCell(1).getParagraphs().get(0);
|
// XWPFParagraph para = table.getRow(number).getCell(1).getParagraphs().get(0);
|
||||||
// XWPFRun run = para.createRun();//对某个段落设置格式
|
// XWPFRun run = para.createRun();//对某个段落设置格式
|
||||||
@@ -893,32 +957,6 @@ public class WordUtil {
|
|||||||
table.getRow(number).getCell(1).setText(technologyTerritory);
|
table.getRow(number).getCell(1).setText(technologyTerritory);
|
||||||
|
|
||||||
}
|
}
|
||||||
// private static void setCell(XWPFTable table, int number, String fieldName,String technologyTerritory) {
|
|
||||||
//
|
|
||||||
// table.getRow(number).setHeight(500);
|
|
||||||
// CTTblWidth ctTblWidth0 = table.getRow(number).getCell(0).getCTTc().addNewTcPr().addNewTcW();
|
|
||||||
// ctTblWidth0.setType(STTblWidth.DXA);
|
|
||||||
// ctTblWidth0.setW(BigInteger.valueOf(2000));
|
|
||||||
// CTTblWidth ctTblWidth1 = table.getRow(number).getCell(1).getCTTc().addNewTcPr().addNewTcW();
|
|
||||||
// ctTblWidth1.setType(STTblWidth.DXA);
|
|
||||||
// ctTblWidth1.setW(BigInteger.valueOf(5000));
|
|
||||||
//
|
|
||||||
// table.getRow(number).getCell(0).setText(fieldName);
|
|
||||||
// table.getRow(number).getCell(1).setText(technologyTerritory);
|
|
||||||
// }
|
|
||||||
// private static void setCell(XWPFTableRow tableRow, String fieldName,String technologyTerritory) {
|
|
||||||
//
|
|
||||||
// tableRow.setHeight(500);
|
|
||||||
// CTTblWidth ctTblWidth0 = tableRow.getCell(0).getCTTc().addNewTcPr().addNewTcW();
|
|
||||||
// ctTblWidth0.setType(STTblWidth.DXA);
|
|
||||||
// ctTblWidth0.setW(BigInteger.valueOf(3000));
|
|
||||||
// CTTblWidth ctTblWidth1 = tableRow.getCell(1).getCTTc().addNewTcPr().addNewTcW();
|
|
||||||
// ctTblWidth1.setType(STTblWidth.DXA);
|
|
||||||
// ctTblWidth1.setW(BigInteger.valueOf(5000));
|
|
||||||
//
|
|
||||||
// tableRow.getCell(0).setText(fieldName);
|
|
||||||
// tableRow.getCell(1).setText(technologyTerritory);
|
|
||||||
// }
|
|
||||||
|
|
||||||
private static String getLawsContact(List<LoginUser> userList, String lawsContact) {
|
private static String getLawsContact(List<LoginUser> userList, String lawsContact) {
|
||||||
if(com.jero.modules.system.util.StringUtils.isNotBlank(lawsContact)){
|
if(com.jero.modules.system.util.StringUtils.isNotBlank(lawsContact)){
|
||||||
@@ -937,5 +975,21 @@ public class WordUtil {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置单元格边距
|
||||||
|
* @param cell
|
||||||
|
*/
|
||||||
|
public static void cellPadding(XWPFTableCell cell){
|
||||||
|
CTTc ctTc = cell.getCTTc();
|
||||||
|
CTTcPr cttcpr =ctTc.isSetTcPr() ? ctTc.getTcPr() : ctTc.addNewTcPr();
|
||||||
|
CTTcMar ctTcMar = cttcpr.isSetTcMar() ? cttcpr.getTcMar() : cttcpr.addNewTcMar();
|
||||||
|
(ctTcMar.isSetLeft() ? ctTcMar.getLeft() : ctTcMar.addNewLeft()).setW(BigInteger.valueOf(119));//左边距
|
||||||
|
(ctTcMar.isSetTop() ? ctTcMar.getTop() : ctTcMar.addNewTop()).setW(BigInteger.valueOf(63));//上边距
|
||||||
|
// (ctTcMar.isSetRight() ? ctTcMar.getRight() : ctTcMar.addNewRight()).setW(BigInteger.valueOf(100));
|
||||||
|
// (ctTcMar.isSetBottom() ? ctTcMar.getBottom() : ctTcMar.addNewBottom()).setW(BigInteger.valueOf(100));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user