Package org.apache.poi.xssf.usermodel

Examples of org.apache.poi.xssf.usermodel.XSSFCellStyle


    }
    if (bg != null)
    {
      if (hssfCellStyle instanceof XSSFCellStyle)
      {
        final XSSFCellStyle xssfCellStyle = (XSSFCellStyle) hssfCellStyle;
        if (BorderStyle.NONE.equals(bg.getBottom().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderBottom(styleKey.getBorderStrokeBottom());
          xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.BOTTOM,
              createXSSFColor(styleKey.getExtendedColorBottom()));
        }
        if (BorderStyle.NONE.equals(bg.getTop().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderTop(styleKey.getBorderStrokeTop());
          xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.TOP,
              createXSSFColor(styleKey.getExtendedColorTop()));
        }
        if (BorderStyle.NONE.equals(bg.getLeft().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderLeft(styleKey.getBorderStrokeLeft());
          xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.LEFT,
              createXSSFColor(styleKey.getExtendedColorLeft()));
        }
        if (BorderStyle.NONE.equals(bg.getRight().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderRight(styleKey.getBorderStrokeRight());
          xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.RIGHT,
              createXSSFColor(styleKey.getExtendedColorRight()));
        }
        if (bg.getBackgroundColor() != null)
        {
          xssfCellStyle.setFillForegroundColor(createXSSFColor(styleKey.getExtendedColor()));
          hssfCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
        }
      }
      else
      {
View Full Code Here


            }else {
                 String cellStyleStr = attributes.getValue("s");
                 if(null != cellStyleStr){
                    nextIsString = true;
                    int styleIndex = Integer.parseInt(cellStyleStr);
                    XSSFCellStyle style = stylesTable.getStyleAt(styleIndex);
                    formatIndex = style.getDataFormat();
                    String formateString = style.getDataFormatString();
                    if (DATE_FORMATE_STRING_US.equals(formateString))
                    {
                        dataType = CellDataType.DATE;
                    }else{
                        nextIsString = false;
View Full Code Here

   {
      boolean bDate = false;
      double d = cell.getNumericCellValue();
      if (HSSFDateUtil.isValidExcelDate(d))
      {
         XSSFCellStyle style = cell.getCellStyle();
         int i = style.getDataFormat();
         switch (i)
         {
            case 0xe : // m/d/yy
            case 0xf : // d-mmm-yy
            case 0x10 : // d-mmm
View Full Code Here

    int nf1 = st.putNumberFormat("yyyy-mm-dd");
    int nf2 = st.putNumberFormat("yyyy-mm-DD");
    assertEquals(nf1, st.putNumberFormat("yyyy-mm-dd"));

    st.putStyle(new XSSFCellStyle(st));

    // Save and re-load
    st = XSSFTestDataSamples.writeOutAndReadBack(wb).getStylesSource();

    assertNotNull(st.getCTStylesheet());
View Full Code Here

    // 0 is the empty default
    if(xfs.get(idx).getXfId() > 0) {
      styleXfId = (int) xfs.get(idx).getXfId();
    }

    return new XSSFCellStyle(idx, styleXfId, this, theme);
  }
View Full Code Here

    xf.setFillId(0);
    xf.setBorderId(0);
    xf.setXfId(0);
    int xfSize = styleXfs.size();
    int indexXf = putCellXf(xf);
    return new XSSFCellStyle(indexXf - 1, xfSize - 1, this, theme);
  }
View Full Code Here

                          Java fmt differs from Excel fmt. If Excel date format is mm/dd/yyyy, Java
                          will always be 00 for date since "m" is minutes of the hour.*/
                          strValue = new CellDateFormatter(dateFmt).format(cell.getDateCellValue());
//                        td.text(strValue);
                      }else{
                        XSSFCellStyle cellStyle = xssfCell.getCellStyle();
                        if(cellStyle!=null && cellStyle.getDataFormatString()!=null){
//                           String dateFmt = cell.getCellStyle().getDataFormatString();
                              /* strValue = new SimpleDateFormat(dateFmt).format(date); - won't work as
                              Java fmt differs from Excel fmt. If Excel date format is mm/dd/yyyy, Java
                              will always be 00 for date since "m" is minutes of the hour.*/
                           strValue = new HSSFDataFormatter().formatRawCellContents(cell.getNumericCellValue(), cellStyle.getDataFormat(), cellStyle.getDataFormatString());
                        }else{
                            strValue = String.valueOf(xssfCell.getNumericCellValue());
                        }
//                        xssfCell.getCellStyle().getDataFormatString();
//                        td.text(String.valueOf(cell.getNumericCellValue()));
                      }
                    }
                    td.text(strValue);
                  }else if(cell.getCellType()==Cell.CELL_TYPE_STRING){
                    td.text(cell.getStringCellValue());
                  }
                  if(sheet instanceof HSSFSheet){
                    HSSFSheet hssfSheet = (HSSFSheet)sheet;
                    HSSFCell hssfCell = (HSSFCell)cell;
                    HSSFCellStyle style = hssfCell.getCellStyle();
//                    判断一下如果式样中有斜杠,那么写一个斜杠
                   
                    HSSFPalette palette = hssfSheet.getWorkbook().getCustomPalette();
                    styleApplier4XLS(td,style,hssfSheet.getWorkbook(),palette);
                  }else{
                    XSSFSheet xssfSheet = (XSSFSheet)sheet;
                    XSSFCell xssfCell = (XSSFCell)cell;
                    XSSFCellStyle style = xssfCell.getCellStyle();
//                    判断一下如果式样中有斜杠,那么写一个斜杠
                    styleApplier4XLSX(td,style,xssfSheet.getWorkbook());
                  }
                }

View Full Code Here

    public XSSFHtmlHelperV2(XSSFWorkbook wb) {
        this.wb = wb;
    }

    public void colorStyles(CellStyle style, Formatter out) {
        XSSFCellStyle cs = (XSSFCellStyle) style;
        styleColor(out, "background-color", cs.getFillForegroundXSSFColor());
        styleColor(out, "text-color", cs.getFont().getXSSFColor());
    }
View Full Code Here

    public XSSFHtmlHelper(XSSFWorkbook wb) {
        this.wb = wb;
    }

    public void colorStyles(CellStyle style, Formatter out) {
        XSSFCellStyle cs = (XSSFCellStyle) style;
        styleColor(out, "background-color", cs.getFillForegroundXSSFColor());
        styleColor(out, "text-color", cs.getFont().getXSSFColor());
    }
View Full Code Here

               nextDataType = xssfDataType.SST_STRING;
           else if ("str".equals(cellType))
               nextDataType = xssfDataType.FORMULA;
           else {
               // Number, but almost certainly with a special style or format
               XSSFCellStyle style = null;
               if (cellStyleStr != null) {
                   int styleIndex = Integer.parseInt(cellStyleStr);
                   style = stylesTable.getStyleAt(styleIndex);
               } else if (stylesTable.getNumCellStyles() > 0) {
                   style = stylesTable.getStyleAt(0);
               }
               if (style != null) {
                   this.formatIndex = style.getDataFormat();
                   this.formatString = style.getDataFormatString();
                   if (this.formatString == null)
                       this.formatString = BuiltinFormats.getBuiltinFormat(this.formatIndex);
               }
           }
       }
View Full Code Here

TOP

Related Classes of org.apache.poi.xssf.usermodel.XSSFCellStyle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.