Hi

I need help with creating format. I am trying to create a currency format
for Canadian currency. I have to format the amount as CAD#,##0.0000.

If I put CAD, it is not writing the format to excel, but if I put 'CA' or
'$CA', it works.

Can someone please help me figure out what is the issue? 

A sample code I wrote to write to excel is below.

                    Workbook wb = new HSSFWorkbook();
                    Sheet sheet = wb.createSheet("format sheet");
                    CellStyle style;
                    DataFormat format = wb.createDataFormat();
                    Row row;
                    Cell cell;
                    short rowNum = 0;
                    short colNum = 0; 

                    row = sheet.createRow(rowNum++);
                    cell = row.createCell(colNum);
                    cell.setCellValue(11111.25);
                    style = wb.createCellStyle();
                    style.setDataFormat(format.getFormat("CAD#,##0.0000"));
                    cell.setCellStyle(style);

                    FileOutputStream fileOut;
                        try
                        {
                                fileOut = new 
FileOutputStream("c:/workbook.xls");
                                 wb.write(fileOut);
                                    fileOut.close();
                        }
                        catch (FileNotFoundException e)
                        {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
                        catch (IOException e)
                        {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }



--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Currency-format-with-three-characters-tp5713092.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