Пример #1
0
  /**
   * セルの縮小して全体を表示する
   *
   * @param nRow 行データ
   * @return 有効列数
   */
  public static void setShrinkToFitForCell(XSSFWorkbook wb, XSSFSheet sheet, int nRow, int nCol) {

    XSSFRow row = OoxmlUtil.getRowAnyway(sheet, nRow);
    XSSFCell cell = OoxmlUtil.getCellAnyway(row, nCol);
    CellStyle styletmp = cell.getCellStyle();
    CellStyle newStyletmp = wb.createCellStyle();
    newStyletmp.cloneStyleFrom(styletmp);
    newStyletmp.setWrapText(false); // 折り返して全体を表示する
    newStyletmp.setShrinkToFit(true); // 縮小して全体を表示する
    cell.setCellStyle(newStyletmp);
  }
Пример #2
0
 /**
  * 上線は太線のセル行を探す
  *
  * @param nRow 行データ
  * @return 有効列数
  */
 public static int getRowForBold(XSSFSheet sheet, int nRow, int pageRowNum) {
   int nRowIndex = nRow;
   for (nRowIndex = nRow; nRowIndex > (nRow - pageRowNum); nRow--) {
     XSSFRow row = OoxmlUtil.getRowAnyway(sheet, nRow);
     if (row != null) {
       XSSFCell cell = row.getCell(0);
       XSSFCellStyle styletmp = cell.getCellStyle();
       short borderTopnum = styletmp.getBorderTop();
       short borderBold = XSSFCellStyle.BORDER_MEDIUM;
       if (styletmp.getBorderTop() == (XSSFCellStyle.BORDER_MEDIUM)) {
         break;
       }
     }
   }
   return nRowIndex;
 }
Пример #3
0
  public static Map<String, XSSFCellStyle> createCellStyle(XSSFWorkbook wb) {
    Map<String, XSSFCellStyle> styleMap = new HashMap<String, XSSFCellStyle>();
    Color color = new Color(255, 255, 255);
    Short fontSize8 = 7;
    Short fontSize10 = 10;
    Short fontSize12 = 12;
    Short fontSize16 = 16;
    styleMap.put(
        "normal",
        OoxmlUtil.createTableDataCellStyle(
            wb, false, false, false, false, color, fontSize10, false));
    styleMap.put(
        "normalSize8",
        OoxmlUtil.createTableDataCellStyle(
            wb, false, false, false, false, color, fontSize8, false));
    styleMap.put(
        "normalSize12",
        OoxmlUtil.createTableDataCellStyle(
            wb, false, false, false, false, color, fontSize12, false));
    styleMap.put(
        "normalSize16",
        OoxmlUtil.createTableDataCellStyle(
            wb, false, false, false, false, color, fontSize16, true));
    styleMap.put(
        "normalSizeFalse16",
        OoxmlUtil.createTableDataCellStyle(
            wb, false, false, false, false, color, fontSize16, false));
    styleMap.put(
        "isTop",
        OoxmlUtil.createTableDataCellStyle(
            wb, true, false, false, false, color, fontSize10, false));
    styleMap.put(
        "isTopSize16",
        OoxmlUtil.createTableDataCellStyle(wb, true, false, false, false, color, fontSize16, true));
    styleMap.put(
        "isBottom",
        OoxmlUtil.createTableDataCellStyle(
            wb, false, true, false, false, color, fontSize10, false));
    styleMap.put(
        "isLeft",
        OoxmlUtil.createTableDataCellStyle(
            wb, false, false, true, false, color, fontSize10, false));
    styleMap.put(
        "isLeftSize16",
        OoxmlUtil.createTableDataCellStyle(wb, false, false, true, false, color, fontSize16, true));
    styleMap.put(
        "isRight",
        OoxmlUtil.createTableDataCellStyle(
            wb, false, false, false, true, color, fontSize10, false));
    styleMap.put(
        "isTopAndLeft",
        OoxmlUtil.createTableDataCellStyle(wb, true, false, true, false, color, fontSize10, false));
    styleMap.put(
        "isTopAndLeftSize16",
        OoxmlUtil.createTableDataCellStyle(wb, true, false, true, false, color, fontSize16, true));
    styleMap.put(
        "isTopAndRight",
        OoxmlUtil.createTableDataCellStyle(wb, true, false, false, true, color, fontSize10, false));
    styleMap.put(
        "isTopAndRightSize16",
        OoxmlUtil.createTableDataCellStyle(wb, true, false, false, true, color, fontSize16, true));
    styleMap.put(
        "isBottomAndLeft",
        OoxmlUtil.createTableDataCellStyle(wb, false, true, true, false, color, fontSize10, false));
    styleMap.put(
        "isBottomAndLeftSize12",
        OoxmlUtil.createTableDataCellStyle(wb, false, true, true, false, color, fontSize12, true));
    styleMap.put(
        "isBottomAndLeftSize16",
        OoxmlUtil.createTableDataCellStyle(wb, false, true, true, false, color, fontSize16, true));
    styleMap.put(
        "isBottomAndRight",
        OoxmlUtil.createTableDataCellStyle(wb, false, true, false, true, color, fontSize10, false));
    styleMap.put(
        "isBottomAndRightSize12",
        OoxmlUtil.createTableDataCellStyle(wb, false, true, false, true, color, fontSize12, true));
    styleMap.put(
        "isBottomAndRightSize16",
        OoxmlUtil.createTableDataCellStyle(wb, false, true, false, true, color, fontSize16, true));
    styleMap.put(
        "isLeftAndRight",
        OoxmlUtil.createTableDataCellStyle(wb, false, false, true, true, color, fontSize10, false));

    return styleMap;
  }