Hi, I have problem when try to apply date format in existing xls file. The program works correctly when creating new file, but when I read existing file and adding data, format is not applied. My code: initialization method: dataFormat = wb.createDataFormat(); cellStyle = new HSSFCellStyle[metadata.getNumFields()]; String format; for (short i=0;i<metadata.getNumFields();i++){ cellStyle[i] = wb.createCellStyle(); format = metadata.getField(i).getFormatStr(); if (format!=null){ cellStyle[i].setDataFormat(dataFormat.getFormat(format)); } }
writing method: for (short i=0;i<metadata.getNumFields();i++){ colNum = (short)(firstColumn + i); cell = row.createCell(colNum); value = record.getField(i).getValue(); if (value == null) continue; cell.setCellStyle(cellStyle[i]); cell.setCellValue((Date)value); } Initialization method is called once and writing method can be called many times. When I create new file formats are OK, but when I try to add data to existing file (new sheet or only add one more time the same data to existing sheet) new dates are visible as integers. Thanks for any help Agata Vackova --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] Mailing List: http://jakarta.apache.org/site/mail2.html#poi The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/