Sorry to say this but I cannot reproduce the problem. When I run this piece
of code;

    public FormatTest(String filename) throws IOException {
        DataFormat format = null;
        CellStyle cellStyle = null;
        Workbook workbook = null;
        Sheet sheet = null;
        Row row = null;
        Cell cell = null;
        FileOutputStream fos = null;
        BufferedOutputStream bos = null;
        StringBuilder refersToFormula = null;
        if(filename.endsWith(".xlsx")) {
            workbook = new XSSFWorkbook();
        } else {
            workbook = new HSSFWorkbook();
        }
        try {
            
            format = workbook.createDataFormat();
            
            sheet = workbook.createSheet("Format Test");
            
            row = sheet.createRow(0);
            cell = row.createCell(0);
            
            cellStyle = workbook.createCellStyle();
            cellStyle.setDataFormat(format.getFormat("hh:mm"));
            //cell.setCellStyle(cellStyle);
            cell.setCellValue(10.5);
            cell.setCellStyle(cellStyle);
            
            fos = new FileOutputStream(filename);
            bos = new BufferedOutputStream(fos);
            
            workbook.write(bos);
        }
        finally {
            if(bos != null) {
                bos.close();
            }
        }
    }

I see a workbook with ne sheet, that sheet has a single cell the contains
the value 12:00 which I am guessing is what you wanted to see.

Canm I ask one question though, are you referring to the value you see in
the forumla bar - as I think it is called. It is the area you see Excel
reflect the cells contents and where you can edit the contents of a cell? If
so, that is perfectly normal, that bar will display the raw contents of the
cell so to speak and you will only see the formatted value displayed in the
cell itself.

--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Create-cell-in-Hours-Format-tp5515970p5521164.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to