Search in sources :

Example 21 with XWPFTableRow

use of org.apache.poi.xwpf.usermodel.XWPFTableRow in project Gargoyle by callakrsos.

the class MSWord method addTableCell.

private static void addTableCell(DIRECTION dir, XWPFTable table, int currentRow, int span) {
    int dirRowIndex = 0;
    if (DIRECTION._0 == dir) {
        dirRowIndex = currentRow + 1;
    } else if (DIRECTION.UP_DOWN == dir) {
        dirRowIndex = currentRow - 1;
    }
    XWPFTableRow belowRow = table.getRow(dirRowIndex);
    if (belowRow != null) {
        // 병합된 span만큼 셀을 추가한다.
        for (int i = 0; i < span - 1; i++) {
            belowRow.createCell();
        }
    }
}
Also used : XWPFTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow)

Example 22 with XWPFTableRow

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

the class WordHelper method fillDecNationalPlanData.

private XWPFTable fillDecNationalPlanData(XWPFTable table, List<DecNationalPlan> decNationalPlans) {
    if (CollectionUtil.isEmpty(decNationalPlans)) {
        return table;
    }
    if (decNationalPlans.size() > 1) {
        int height = table.getRow(1).getHeight();
        for (int i = 1; i < decNationalPlans.size(); i++) {
            table.createRow().setHeight(height);
        }
    }
    List<XWPFTableRow> rows = table.getRows();
    List<XWPFTableCell> cells;
    int rowCount = 1;
    for (DecNationalPlan decNationalPlan : decNationalPlans) {
        cells = rows.get(rowCount).getTableCells();
        String value = decNationalPlan.getMaterialName();
        if (StringUtil.notEmpty(value)) {
            cells.get(0).setText(value);
        }
        value = decNationalPlan.getIsbn();
        if (StringUtil.notEmpty(value)) {
            cells.get(1).setText(value);
        }
        value = decNationalPlan.getRankText();
        if (StringUtil.notEmpty(value)) {
            cells.get(2).setText(value);
        }
        value = decNationalPlan.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) DecNationalPlan(com.bc.pmpheep.back.po.DecNationalPlan) XWPFTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow)

Example 23 with XWPFTableRow

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

the class WordHelper method fillDecAcadeRewardData.

private XWPFTable fillDecAcadeRewardData(XWPFTable table, List<DecAcadeReward> decAcadeRewards) {
    if (CollectionUtil.isEmpty(decAcadeRewards)) {
        return table;
    }
    if (decAcadeRewards.size() > 1) {
        int height = table.getRow(1).getHeight();
        for (int i = 1; i < decAcadeRewards.size(); i++) {
            table.createRow().setHeight(height);
        }
    }
    List<XWPFTableRow> rows = table.getRows();
    List<XWPFTableCell> cells;
    int rowCount = 1;
    for (DecAcadeReward decAcadeReward : decAcadeRewards) {
        cells = rows.get(rowCount).getTableCells();
        String value = decAcadeReward.getRewardName();
        if (StringUtil.notEmpty(value)) {
            cells.get(0).setText(value);
        }
        Date rewardDate = decAcadeReward.getRewardDate();
        if (null != rewardDate) {
            value = sdf.format(rewardDate);
            cells.get(1).setText(value);
        }
        Integer type = decAcadeReward.getAwardUnit();
        if (null != type) {
            switch(type) {
                case 0:
                    value = "无";
                    break;
                case 1:
                    value = "国际";
                    break;
                case 2:
                    value = "国家";
                    break;
                case 3:
                    value = "省部";
                    break;
                case 4:
                    value = "市";
                    break;
                default:
                    value = "无";
                    break;
            }
            cells.get(2).setText(value);
        }
        value = decAcadeReward.getNote();
        if (StringUtil.notEmpty(value)) {
            cells.get(3).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) DecAcadeReward(com.bc.pmpheep.back.po.DecAcadeReward) Date(java.util.Date) XWPFTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow)

Example 24 with XWPFTableRow

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

the class WordHelper method fillDecSciData.

private XWPFTable fillDecSciData(XWPFTable table, List<DecSci> decScis) {
    if (CollectionUtil.isEmpty(decScis)) {
        return table;
    }
    if (decScis.size() > 1) {
        int height = table.getRow(1).getHeight();
        for (int i = 1; i < decScis.size(); i++) {
            table.createRow().setHeight(height);
        }
    }
    List<XWPFTableRow> rows = table.getRows();
    List<XWPFTableCell> cells;
    int rowCount = 1;
    for (DecSci decSci : decScis) {
        cells = rows.get(rowCount).getTableCells();
        String value = decSci.getPaperName();
        if (StringUtil.notEmpty(value)) {
            cells.get(0).setText(value);
        }
        value = decSci.getJournalName();
        if (StringUtil.notEmpty(value)) {
            cells.get(1).setText(value);
        }
        value = decSci.getFactor();
        if (StringUtil.notEmpty(value)) {
            cells.get(2).setText(value);
        }
        Date publishDate = decSci.getPublishDate();
        if (null != publishDate) {
            value = sdf.format(publishDate);
            cells.get(3).setText(value);
        }
        value = decSci.getNote();
        if (StringUtil.notEmpty(value)) {
            cells.get(4).setText(value);
        }
        for (XWPFTableCell cell : cells) {
            cell.setVerticalAlignment(XWPFVertAlign.CENTER);
        }
        rowCount++;
    }
    return table;
}
Also used : DecSci(com.bc.pmpheep.back.po.DecSci) XWPFTableCell(org.apache.poi.xwpf.usermodel.XWPFTableCell) Date(java.util.Date) XWPFTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow)

Example 25 with XWPFTableRow

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

the class WordHelper method fillDecTextbookData.

private XWPFTable fillDecTextbookData(XWPFTable table, List<DecTextbook> decTextbooks) {
    if (CollectionUtil.isEmpty(decTextbooks)) {
        return table;
    }
    if (decTextbooks.size() > 1) {
        int height = table.getRow(1).getHeight();
        for (int i = 1; i < decTextbooks.size(); i++) {
            table.createRow().setHeight(height);
        }
    }
    List<XWPFTableRow> rows = table.getRows();
    List<XWPFTableCell> cells;
    int rowCount = 1;
    for (DecTextbook decTextbook : decTextbooks) {
        cells = rows.get(rowCount).getTableCells();
        String value = decTextbook.getMaterialName();
        if (StringUtil.notEmpty(value)) {
            cells.get(0).setText(value);
        }
        /* 0=无/1=国家/2=省部/3=协编/4=校本/5=其他教材 */
        Integer rank = decTextbook.getRank();
        if (null != rank) {
            switch(rank) {
                case 0:
                    value = "无";
                    break;
                case 1:
                    value = "国家";
                    break;
                case 2:
                    value = "省部";
                    break;
                case 3:
                    value = "协编";
                    break;
                case 4:
                    value = "校本";
                    break;
                case 5:
                    value = "其他";
                    break;
                default:
                    value = "无";
                    break;
            }
            cells.get(1).setText(value);
        }
        // 0=无/1=主编/2=副主编/3=编委
        Integer position = decTextbook.getPosition();
        if (null != position) {
            switch(position) {
                case 1:
                    value = "主编";
                    break;
                case 2:
                    value = "副主编";
                    break;
                case 3:
                    value = "编委";
                    break;
                default:
                    value = "无";
                    break;
            }
            cells.get(2).setText(value);
        }
        value = decTextbook.getIsDigitalEditor() ? "是" : "否";
        cells.get(3).setText(value);
        Date publishDate = decTextbook.getPublishDate();
        if (null != publishDate) {
            value = sdf.format(publishDate);
            cells.get(4).setText(value);
        }
        value = decTextbook.getPublisher();
        if (StringUtil.notEmpty(value)) {
            cells.get(5).setText(value);
        }
        value = decTextbook.getIsbn();
        if (StringUtil.notEmpty(value)) {
            cells.get(6).setText(value);
        }
        value = decTextbook.getNote();
        if (StringUtil.notEmpty(value)) {
            cells.get(7).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) DecTextbook(com.bc.pmpheep.back.po.DecTextbook) 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