Package org.apache.poi.hssf.usermodel

Examples of org.apache.poi.hssf.usermodel.HSSFDataFormat


                convertVAlignment(getVerticalAlignment().getCode());
            style.setVerticalAlignment(cnvvalign);
            style.setFillPattern((short)getShade());

            Workbook workbook = getWorkbook();
            HSSFDataFormat dataformat = workbook.createDataFormat();
            if (getShade() == 1) {
                // TODO: change to constant when upgrade to new HSSF
                // solid w/foreground, bg doesn't matter
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("shade = 1");
                }
                HSSFColor color =
                    (HSSFColor)colorhash.get(getBackgroundColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("s1 BG couldn't find color for "
                                + getBackgroundColor().toString());
                    }
                    color = new HSSFColor.WHITE();
                }
                style.setFillForegroundColor(color.getIndex());
                color = (HSSFColor)colorhash.get(getPatternColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("s1 PC couldn't find color for "
                                + getPatternColor().toString());
                    }
                    color = new HSSFColor.BLACK();
                }
                style.setFillBackgroundColor(color.getIndex());
            } else {
                HSSFColor color =
                    (HSSFColor)colorhash.get(getBackgroundColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug(
                            "BG couldn't find color for "
                                + getBackgroundColor().toString());
                    }
                    color = new HSSFColor.BLACK();
                }
                style.setFillBackgroundColor(color.getIndex());
                color = (HSSFColor)colorhash.get(getPatternColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("PC couldn't find color for "
                                + getPatternColor().toString());
                    }
                    color = new HSSFColor.WHITE();
                }
                style.setFillForegroundColor(color.getIndex());
            }
            style.setWrapText(getWrapText());
            style.setLocked(true);

            String format = null;
            try {
                format = getFormat();
            } catch (NullPointerException e) {
                format = _general_format;
            }

            if (!format.equals(_general_format)) {
                short valuenumber;
                format = kludgeForGnumericMisformats(format);
                format = kludgeForGnumericDateDivergence(format);
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("setting format to " + format);
                }
                Object o =
                    workbook.getValidate(format, dataformat.getFormat(format));
                Short sh = null;
                sh = (Short)o;
                valuenumber = sh.shortValue();
                style.setDataFormat(valuenumber);
            }
View Full Code Here


                convertVAlignment(getVerticalAlignment().getCode());
            style.setVerticalAlignment(cnvvalign);
            style.setFillPattern((short)getShade());

            Workbook workbook = getWorkbook();
            HSSFDataFormat dataformat = workbook.createDataFormat();
            if (getShade() == 1) {
                // TODO: change to constant when upgrade to new HSSF
                // solid w/foreground, bg doesn't matter
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("shade = 1");
                }
                HSSFColor color =
                    (HSSFColor)colorhash.get(getBackgroundColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("s1 BG couldn't find color for "
                                + getBackgroundColor().toString());
                    }
                    color = new HSSFColor.WHITE();
                }
                style.setFillForegroundColor(color.getIndex());
                color = (HSSFColor)colorhash.get(getPatternColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("s1 PC couldn't find color for "
                                + getPatternColor().toString());
                    }
                    color = new HSSFColor.BLACK();
                }
                style.setFillBackgroundColor(color.getIndex());
            } else {
                HSSFColor color =
                    (HSSFColor)colorhash.get(getBackgroundColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug(
                            "BG couldn't find color for "
                                + getBackgroundColor().toString());
                    }
                    color = new HSSFColor.BLACK();
                }
                style.setFillBackgroundColor(color.getIndex());
                color = (HSSFColor)colorhash.get(getPatternColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("PC couldn't find color for "
                                + getPatternColor().toString());
                    }
                    color = new HSSFColor.WHITE();
                }
                style.setFillForegroundColor(color.getIndex());
            }
            style.setWrapText(getWrapText());
            style.setLocked(true);

            String format = null;
            try {
                format = getFormat();
            } catch (NullPointerException e) {
                format = _general_format;
            }

            if (!format.equals(_general_format)) {
                short valuenumber;
                format = kludgeForGnumericMisformats(format);
                format = kludgeForGnumericDateDivergence(format);
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("setting format to " + format);
                }
                Object o =
                    workbook.getValidate(format, dataformat.getFormat(format));
                Short sh = null;
                sh = (Short)o;
                valuenumber = sh.shortValue();
                style.setDataFormat(valuenumber);
            }
View Full Code Here

       
        switch (cellValueType) {
            case (HSSFCell.CELL_TYPE_STRING):
                return cell.getRichStringCellValue().getString();
            case (HSSFCell.CELL_TYPE_NUMERIC):
                final HSSFDataFormat dataFormat = workbook.createDataFormat();
              if (HSSFDateUtil.isCellDateFormatted(cell))
                return excelDateToString(dataFormat, cell);
              else
                return excelNumberToString(dataFormat, cell);
            case (HSSFCell.CELL_TYPE_BLANK):
View Full Code Here

  public void setUp() {
    wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("new sheet");
    style = wb.createCellStyle();
    HSSFDataFormat fmt = wb.createDataFormat();
    style.setDataFormat(fmt.getFormat("hh:mm:ss"));

    cell11 = sheet.createRow(0).createCell(0);
    form = new HSSFDataFormatter();

    evaluator = new HSSFFormulaEvaluator(wb);
View Full Code Here

            short cnvvalign = convertVAlignment(getVerticalAlignment().getCode());
            style.setVerticalAlignment(cnvvalign);
            style.setFillPattern((short)getShade());

      Workbook workbook = getWorkbook();
      HSSFDataFormat dataformat = workbook.createDataFormat();
            if (getShade() == 1) {
                // TODO: change to constant when upgrade to new HSSF
                // solid w/foreground, bg doesn't matter
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("shade = 1");
                }
                HSSFColor color = (HSSFColor)colorhash.get(getBackgroundColor().toString());
                if (color == null) {
                    getLogger().debug("s1 BG couldn't find color for " + getBackgroundColor().toString());
                    color = new HSSFColor.WHITE();
                }
                style.setFillForegroundColor(color.getIndex());
                color = (HSSFColor)colorhash.get(getPatternColor().toString());
                if (color == null) {
          if (getLogger().isDebugEnabled()) {
              getLogger().debug("s1 PC couldn't find color for " + getPatternColor().toString());
          }
                    color = new HSSFColor.BLACK();
                }
                style.setFillBackgroundColor(color.getIndex());
            } else {
                HSSFColor color = (HSSFColor)colorhash.get(getBackgroundColor().toString());
                if (color == null) {
          if (getLogger().isDebugEnabled()) {
              getLogger().debug("BG couldn't find color for " + getBackgroundColor().toString());
          }
                    color = new HSSFColor.BLACK();
                }
                style.setFillBackgroundColor(color.getIndex());
                color = (HSSFColor)colorhash.get(getPatternColor().toString());
                if (color == null) {
          if (getLogger().isDebugEnabled()) {
              getLogger().debug("PC couldn't find color for " + getPatternColor().toString());
          }
                    color = new HSSFColor.WHITE();
                }
                style.setFillForegroundColor(color.getIndex());
            }
            style.setWrapText(getWrapText());
            style.setLocked(true);

            String format = null;
            try {
                format = getFormat();
            } catch (NullPointerException e) {
                format = _general_format;
            }

            if (!format.equals(_general_format)) {
        short valuenumber;
                format = kludgeForGnumericMisformats(format);
                format = kludgeForGnumericDateDivergence(format);
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("setting format to " + format);
        }
        Object o = workbook.getValidate(format, dataformat.getFormat(format));
        Short sh = null;
        sh = (Short) o;
        valuenumber = sh.shortValue();
        style.setDataFormat(valuenumber);
            }
View Full Code Here

                if (builtInFormat != -1) {
                    hssfStyle.setDataFormat(builtInFormat);
                }
                else
                {
                    HSSFDataFormat df = workbook.createDataFormat();
                    hssfStyle.setDataFormat(df.getFormat(style.getNumberFormat()));
                }
            }

            if (styleEntry == null) {
                styleEntry = new HSSFCellStyle[2];
View Full Code Here

     *             will be written.
     */
    public void bulletedItemInCell(HSSFWorkbook workbook, String listItem, HSSFCell cell) {
        // A format String must be built to ensure that the contents of the
        // cell appear as a bulleted item.
        HSSFDataFormat format = workbook.createDataFormat();
        String formatString = InCellLists.BULLET_CHARACTER + " @";
        int formatIndex = format.getFormat(formatString);

        // Construct an HSSFCellStyle and set it's data formt to use the
        // object created above.
        HSSFCellStyle bulletStyle = workbook.createCellStyle();
        bulletStyle.setDataFormat((short)formatIndex);
View Full Code Here

                convertVAlignment(getVerticalAlignment().getCode());
            style.setVerticalAlignment(cnvvalign);
            style.setFillPattern((short)getShade());

            Workbook workbook = getWorkbook();
            HSSFDataFormat dataformat = workbook.createDataFormat();
            if (getShade() == 1) {
                // TODO: change to constant when upgrade to new HSSF
                // solid w/foreground, bg doesn't matter
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("shade = 1");
                }
                HSSFColor color =
                    (HSSFColor)colorhash.get(getBackgroundColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("s1 BG couldn't find color for "
                                + getBackgroundColor().toString());
                    }
                    color = new HSSFColor.WHITE();
                }
                style.setFillForegroundColor(color.getIndex());
                color = (HSSFColor)colorhash.get(getPatternColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("s1 PC couldn't find color for "
                                + getPatternColor().toString());
                    }
                    color = new HSSFColor.BLACK();
                }
                style.setFillBackgroundColor(color.getIndex());
            } else {
                HSSFColor color =
                    (HSSFColor)colorhash.get(getBackgroundColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug(
                            "BG couldn't find color for "
                                + getBackgroundColor().toString());
                    }
                    color = new HSSFColor.BLACK();
                }
                style.setFillBackgroundColor(color.getIndex());
                color = (HSSFColor)colorhash.get(getPatternColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("PC couldn't find color for "
                                + getPatternColor().toString());
                    }
                    color = new HSSFColor.WHITE();
                }
                style.setFillForegroundColor(color.getIndex());
            }
            style.setWrapText(getWrapText());
            style.setLocked(true);

            String format = null;
            try {
                format = getFormat();
            } catch (NullPointerException e) {
                format = _general_format;
            }

            if (!_general_format.equals(format)) {
                short valuenumber;
                format = kludgeForGnumericMisformats(format);
                format = kludgeForGnumericDateDivergence(format);
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("setting format to " + format);
                }
                Object o =
                    workbook.getValidate(format, dataformat.getFormat(format));
                Short sh = null;
                sh = (Short)o;
                valuenumber = sh.shortValue();
                style.setDataFormat(valuenumber);
            }
View Full Code Here

                convertVAlignment(getVerticalAlignment().getCode());
            style.setVerticalAlignment(cnvvalign);
            style.setFillPattern((short)getShade());

            Workbook workbook = getWorkbook();
            HSSFDataFormat dataformat = workbook.createDataFormat();
            if (getShade() == 1) {
                // TODO: change to constant when upgrade to new HSSF
                // solid w/foreground, bg doesn't matter
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("shade = 1");
                }
                HSSFColor color =
                    (HSSFColor)colorhash.get(getBackgroundColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("s1 BG couldn't find color for "
                                + getBackgroundColor().toString());
                    }
                    color = new HSSFColor.WHITE();
                }
                style.setFillForegroundColor(color.getIndex());
                color = (HSSFColor)colorhash.get(getPatternColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("s1 PC couldn't find color for "
                                + getPatternColor().toString());
                    }
                    color = new HSSFColor.BLACK();
                }
                style.setFillBackgroundColor(color.getIndex());
            } else {
                HSSFColor color =
                    (HSSFColor)colorhash.get(getBackgroundColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug(
                            "BG couldn't find color for "
                                + getBackgroundColor().toString());
                    }
                    color = new HSSFColor.BLACK();
                }
                style.setFillBackgroundColor(color.getIndex());
                color = (HSSFColor)colorhash.get(getPatternColor().toString());
                if (color == null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("PC couldn't find color for "
                                + getPatternColor().toString());
                    }
                    color = new HSSFColor.WHITE();
                }
                style.setFillForegroundColor(color.getIndex());
            }
            style.setWrapText(getWrapText());
            style.setLocked(true);

            String format = null;
            try {
                format = getFormat();
            } catch (NullPointerException e) {
                format = _general_format;
            }

            if (!_general_format.equals(format)) {
                short valuenumber;
                format = kludgeForGnumericMisformats(format);
                format = kludgeForGnumericDateDivergence(format);
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("setting format to " + format);
                }
                Object o =
                    workbook.getValidate(format, dataformat.getFormat(format));
                Short sh = null;
                sh = (Short)o;
                valuenumber = sh.shortValue();
                style.setDataFormat(valuenumber);
            }
View Full Code Here

  public void setUp() {
    wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("new sheet");
    style = wb.createCellStyle();
    HSSFDataFormat fmt = wb.createDataFormat();
    style.setDataFormat(fmt.getFormat("hh:mm:ss"));

    cell11 = sheet.createRow(0).createCell(0);
    form = new HSSFDataFormatter();

    evaluator = new HSSFFormulaEvaluator(wb);
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.usermodel.HSSFDataFormat

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.