Return-Path: X-Original-To: apmail-poi-user-archive@www.apache.org Delivered-To: apmail-poi-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B1A39D9F5 for ; Mon, 24 Jun 2013 22:21:51 +0000 (UTC) Received: (qmail 9931 invoked by uid 500); 24 Jun 2013 22:21:51 -0000 Delivered-To: apmail-poi-user-archive@poi.apache.org Received: (qmail 9883 invoked by uid 500); 24 Jun 2013 22:21:51 -0000 Mailing-List: contact user-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "POI Users List" Delivered-To: mailing list user@poi.apache.org Delivered-To: moderator for user@poi.apache.org Received: (qmail 55249 invoked by uid 99); 24 Jun 2013 21:54:59 -0000 X-ASF-Spam-Status: No, hits=2.0 required=5.0 tests=SPF_NEUTRAL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: error (athena.apache.org: encountered temporary error during SPF processing of domain of anjanajose@gmail.com) Date: Mon, 24 Jun 2013 14:54:14 -0700 (PDT) From: anjanajose To: user@poi.apache.org Message-ID: <1372110854431-5713092.post@n5.nabble.com> Subject: Currency format with three characters MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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: user-unsubscribe@poi.apache.org For additional commands, e-mail: user-help@poi.apache.org