This should help: http://jakarta.apache.org/poi/hssf/quick-guide.html#DataFormats
~ amol > -----Original Message----- > From: Daniele Renda [mailto:[EMAIL PROTECTED] > Sent: Monday, September 19, 2005 9:38 AM > To: POI Users List > Subject: Re: Help with HSSF set NUMERIC Cell Value > > > I have tried to set BigDecimal.setscale(2), but after the value that > HSSF want is a double, and the double value have only one decimal. > In particolare it is: > BigDecimal importo=new BigDecimal("0.00"); > cell.setCellValue(importo.setscale(2).toDoubleValue()) --> > here I loss > one decimal precision!! > > Therefore the only way I think it is the second solution. Can someone > write me the code to use HSSFDataFormat with only the first 2 > decimals? > I have tried to do this but witout success. > > Thank's > > Daniele > > Amol Deshmukh ha scritto: > > 2 ways you can resolve this issue: > > 1. If you need only 2 decimal precision, round to 2 decimals > > in Java and set the value. > > 2. If you need the full precision, but want to display > > only the first 2 decimals, set the value as you are doing now > > and use the HSSFDataFormat class to set the cell's display > > format to show only 2 decimal places. > > > > Regards, > > ~ amol > > > > > > > >>-----Original Message----- > >>From: Daniele Renda [mailto:[EMAIL PROTECTED] > >>Sent: Sunday, September 18, 2005 3:28 PM > >>To: [email protected] > >>Subject: Help with HSSF set NUMERIC Cell Value > >> > >> > >>Hello, I have a problem when I try to write a .xls file in > >>with there is > >>a cell with a numeric value. Infact, I use a BigDecimal object in my > >>application with scale(2), that rappresent the number in the format > >>99.99, with 2 decimal. But when I write the cell I have to write the > >>cell with double value because HSSF don't support any format. > >>So in my .xls file I have the cell with a value that don't have 2 > >>decimal.For exemple, if I want to write 150.00, HSSF write > >>150 on .xls file. > >> > >>Anyone can help me? > >>Thanks > >> > >> > >> > >>------------------------------------------------------------ > --------- > >>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/ > >> > > > > > > > --------------------------------------------------------------------- > > 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/ > > > > > > --------------------------------------------------------------------- > 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/ > --------------------------------------------------------------------- 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/
