I am using POI-3.10.1 and Java 1.5 to generate excel files which contains date fields whose formats are
dd-mmm-yy
.
Eg: 24-Nov-15
This is the sample code :
Workbook wb = new SXSSFWorkbook();
SXSSFSheet sheet = (SXSSFSheet) wb.createSheet(sheetName);
// Create date formatter
CellStyle dateCellStyle = wb.createCellStyle();
DataFormat dataFormat = wb.createDataFormat();
short format = dataFormat.getFormat("dd-mmm-yy");
dateCellStyle.setDataFormat(format);
Row row = sheet.createRow(rowIndex);
Cell dateCell = row.createCell(columnIndex);
dateCell.setCellValue(dataValue);
dateCell.setCellStyle(dateCellStyle);
The problem is this, when I open and select a date field in the generated excel file in Windows, the format of the Cell is shown as Custom
.
Following is the steps to recreate/get the issue in Windows:
- Select a date cell
- Right click on the cell and select
Format Cells...
option
- The opened window, the type of the cell is selected as Custom, even though there is a matching type under the Date formats
Really appreciate if any one can give/show directions or a solution to show the this dd-mmm-yy
formatted dates under Date
field styles.