Search in sources :

Example 26 with XWPFTableRow

use of org.apache.poi.xwpf.usermodel.XWPFTableRow in project pmph by BCSquad.

the class WordHelper method fillDecLastPositionData.

private XWPFTable fillDecLastPositionData(XWPFTable table, List<DecLastPosition> decLastPositions) {
    if (CollectionUtil.isEmpty(decLastPositions)) {
        return table;
    }
    if (decLastPositions.size() > 1) {
        int height = table.getRow(1).getHeight();
        for (int i = 1; i < decLastPositions.size(); i++) {
            table.createRow().setHeight(height);
        }
    }
    List<XWPFTableRow> rows = table.getRows();
    List<XWPFTableCell> cells;
    int rowCount = 1;
    for (DecLastPosition decLastPosition : decLastPositions) {
        cells = rows.get(rowCount).getTableCells();
        String value = decLastPosition.getMaterialName();
        if (StringUtil.notEmpty(value)) {
            cells.get(0).setText(value);
        }
        // 0=无/1=主编/2=副主编/3=编委
        Integer position = decLastPosition.getPosition();
        if (null != position) {
            switch(position) {
                case 1:
                    value = "主编";
                    break;
                case 2:
                    value = "副主编";
                    break;
                case 3:
                    value = "编委";
                    break;
                default:
                    value = "无";
                    break;
            }
            cells.get(1).setText(value);
        }
        value = decLastPosition.getIsDigitalEditor() ? "是" : "否";
        cells.get(2).setText(value);
        value = decLastPosition.getPublisher();
        if (StringUtil.notEmpty(value)) {
            cells.get(3).setText(value);
        }
        Date publishDate = decLastPosition.getPublishDate();
        if (null != publishDate) {
            value = sdf.format(publishDate);
            cells.get(4).setText(value);
        }
        value = decLastPosition.getNote();
        if (!StringUtil.isEmpty(value)) {
            cells.get(5).setText(value);
        }
        for (XWPFTableCell cell : cells) {
            cell.setVerticalAlignment(XWPFVertAlign.CENTER);
        }
        rowCount++;
    }
    return table;
}
Also used : BigInteger(java.math.BigInteger) XWPFTableCell(org.apache.poi.xwpf.usermodel.XWPFTableCell) DecLastPosition(com.bc.pmpheep.back.po.DecLastPosition) Date(java.util.Date) XWPFTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow)

Example 27 with XWPFTableRow

use of org.apache.poi.xwpf.usermodel.XWPFTableRow in project pmph by BCSquad.

the class WordHelper method fillDecPublishRewardData.

private XWPFTable fillDecPublishRewardData(XWPFTable table, List<DecPublishReward> decPublishRewards) {
    if (CollectionUtil.isEmpty(decPublishRewards)) {
        return table;
    }
    if (decPublishRewards.size() > 1) {
        int height = table.getRow(1).getHeight();
        for (int i = 1; i < decPublishRewards.size(); i++) {
            table.createRow().setHeight(height);
        }
    }
    List<XWPFTableRow> rows = table.getRows();
    List<XWPFTableCell> cells;
    int rowCount = 1;
    for (DecPublishReward decPublishReward : decPublishRewards) {
        cells = rows.get(rowCount).getTableCells();
        String value = decPublishReward.getRewardName();
        if (StringUtil.notEmpty(value)) {
            cells.get(0).setText(value);
        }
        Date rewardDate = decPublishReward.getRewardDate();
        if (null != rewardDate) {
            value = sdf.format(rewardDate);
            cells.get(1).setText(value);
        }
        value = decPublishReward.getAwardUnit();
        if (StringUtil.notEmpty(value)) {
            cells.get(2).setText(value);
        }
        value = decPublishReward.getNote();
        if (StringUtil.notEmpty(value)) {
            cells.get(3).setText(value);
        }
        for (XWPFTableCell cell : cells) {
            cell.setVerticalAlignment(XWPFVertAlign.CENTER);
        }
        rowCount++;
    }
    return table;
}
Also used : XWPFTableCell(org.apache.poi.xwpf.usermodel.XWPFTableCell) DecPublishReward(com.bc.pmpheep.back.po.DecPublishReward) Date(java.util.Date) XWPFTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow)

Aggregations

XWPFTableRow (org.apache.poi.xwpf.usermodel.XWPFTableRow)27 XWPFTableCell (org.apache.poi.xwpf.usermodel.XWPFTableCell)26 BigInteger (java.math.BigInteger)9 Date (java.util.Date)8 XWPFTable (org.apache.poi.xwpf.usermodel.XWPFTable)6 XWPFParagraph (org.apache.poi.xwpf.usermodel.XWPFParagraph)5 XWPFRun (org.apache.poi.xwpf.usermodel.XWPFRun)5 XWPFDocument (org.apache.poi.xwpf.usermodel.XWPFDocument)3 CTTblPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblPr)3 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 ICell (org.apache.poi.xwpf.usermodel.ICell)2 XWPFSDTCell (org.apache.poi.xwpf.usermodel.XWPFSDTCell)2 XmlCursor (org.apache.xmlbeans.XmlCursor)2 CTDecimalNumber (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber)2 CTHeight (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHeight)2 CTShd (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTShd)2 CTString (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString)2 CTTbl (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl)2 DeclarationEtcBO (com.bc.pmpheep.back.bo.DeclarationEtcBO)1