Package org.apache.poi.hssf.usermodel

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


  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


   * @return an XLS file in form of a byte array (to be streamed for download)
   */
  public byte[] toXLS(int headerRowCount, Short[] numberColumns, Short[] dateColumns) {
    HSSFWorkbook wb = new HSSFWorkbook();
      HSSFSheet s = wb.createSheet();
      HSSFDataFormat dataFormat = wb.createDataFormat();
      HSSFCellStyle dateStyle = wb.createCellStyle();
      dateStyle.setDataFormat(dataFormat.getFormat("dd.mm.yyyy"));
      int rownum = 0;
      for (Iterator<String[]> it = this.iterator(); it.hasNext(); rownum++) {
        HSSFRow r = s.createRow(rownum);
        String[] values = it.next();
        for (short columnnum = 0; columnnum<values.length; columnnum++) {
View Full Code Here

        workbook.write(out);
        out.flush();
    }
   
    protected static HSSFCellStyle createDateCellStyle(HSSFWorkbook workbook) {
        HSSFDataFormat format = workbook.createDataFormat();
        short dateFormatCode = format.getFormat(DATE_FORMAT_AS_NUMBER_DBUNIT);
        HSSFCellStyle dateCellStyle = workbook.createCellStyle();
        dateCellStyle.setDataFormat(dateFormatCode);
        return dateCellStyle;
    }
View Full Code Here

            logger.debug("setNumericCell(cell={}, value={}, workbook={}) - start",
                new Object[] {cell, value, workbook} );

        cell.setCellValue( ((BigDecimal)value).doubleValue() );

        HSSFDataFormat df = workbook.createDataFormat();
        int scale = ((BigDecimal)value).scale();
        short format;
        if(scale <= 0){
            format = df.getFormat("####");
        }
        else {
            String zeros = createZeros(((BigDecimal)value).scale());
            format = df.getFormat("####." + zeros);
        }
        if(logger.isDebugEnabled())
            logger.debug("Using format '{}' for value '{}'.", String.valueOf(format), value);
       
        HSSFCellStyle cellStyleNumber = workbook.createCellStyle();
View Full Code Here

        takeClassValueForKey(dict, "alignment", cellStyle, CellStyle.class, null);
        takeClassValueForKey(dict, "verticalAlignment", cellStyle, CellStyle.class, null);
       
        String formatString = dictValueForKey(dict, "format", null);
        if(formatString != null) {
          HSSFDataFormat format = _workbook.createDataFormat();
          short formatId = format.getFormat(formatString);
          cellStyle.setDataFormat(formatId);
        }
       
        _styles.setObjectForKey(cellStyle, dict);
                if(log.isDebugEnabled()) {
View Full Code Here

        workbook.write(out);
        out.flush();
    }
   
    protected static HSSFCellStyle createDateCellStyle(HSSFWorkbook workbook) {
        HSSFDataFormat format = workbook.createDataFormat();
        short dateFormatCode = format.getFormat(DATE_FORMAT_AS_NUMBER_DBUNIT);
        HSSFCellStyle dateCellStyle = workbook.createCellStyle();
        dateCellStyle.setDataFormat(dateFormatCode);
        return dateCellStyle;
    }
View Full Code Here

            logger.debug("setNumericCell(cell={}, value={}, workbook={}) - start",
                new Object[] {cell, value, workbook} );

        cell.setCellValue( ((BigDecimal)value).doubleValue() );

        HSSFDataFormat df = workbook.createDataFormat();
        int scale = ((BigDecimal)value).scale();
        short format;
        if(scale <= 0){
            format = df.getFormat("####");
        }
        else {
            String zeros = createZeros(((BigDecimal)value).scale());
            format = df.getFormat("####." + zeros);
        }
        if(logger.isDebugEnabled())
            logger.debug("Using format '{}' for value '{}'.", String.valueOf(format), value);
       
        HSSFCellStyle cellStyleNumber = workbook.createCellStyle();
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.