Thanks for your help. I would like to define 5 decimal places to numeric number, 
irrespective whether that numeric number has actual 4 or 10 decimal places. How could 
I do that?

 

I couldn't find the format for displaying 5 decimal places to number in HSSFDataFormat 
class. I tried following format, but it didn't work out. It always return -1 which 
means format is undefined. While in excel, this format is defined under the custom 
category of Format Cells window.

 

short formatIndex = HSSFDataFormat.getBuiltinFormat("#,##0.00000")

short formatIndex = HSSFDataFormat.getBuiltinFormat("#,##0.#####")

 

Thanks

Prashant Patel

 

-----Original Message-----
From: "Mehner, Björn" [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 02, 2003 2:04 AM
To: 'POI Users List'
Subject: AW: How to set different types of fomat and style to different cell

 

yes that is true. You are always modifing the same java object, which

effects all the cells using this

object. Best is to create as many style objects as you have diffrent

sorts of styles. One for percentage, one for floating point numbers and

so on.

 

bye Bodo

 

> -----Ursprüngliche Nachricht-----

> Von: Robert Lowe [mailto:[EMAIL PROTECTED]

> Gesendet: Mittwoch, 1. Oktober 2003 23:49

> An: POI Users List

> Betreff: RE: How to set different types of fomat and style to 

> different

> cell

> 

> 

> A cellstyle can be "shared" by many cells in a workbook. 

> Currently you are

> modifying the "shared" cellstyle, and this affects all cells 

> that use that

> style.

> 

> Instead, try to create a new style using 

> HSSFWorkbook.createCellStyle(), and

> then use cell.setCellStyle(HSSFCellStyle).

> 

> In other words, replace:

> 

>                   HSSFCellStyle cellStyle = cell.getCellStyle();

> 

> with:

> 

>                   HSSFCellStyle cellStyle = 

> workbook.createCellStyle();

>                   cell.setCellStyle(cellStyle);

> 

> - Rob

> 

> 

> -----Original Message-----

> From: Prashant Patel [mailto:[EMAIL PROTECTED]

> Sent: Thursday, October 02, 2003 4:50 AM

> To: [EMAIL PROTECTED]

> Subject: How to set different types of fomat and style to 

> different cell

> 

> 

> 

> 

> How can I set different types of format (i.e percentage, general,

> Numeric with 2 or 3 decimal places) and style for different cells in

> same worksheet? I used following code to set different format for

> different cell, but it applies whatever format I set in the 

> last cell to

> all cells in the worksheet.

> 

> 

> 

>                   HSSFCellStyle cellStyle = cell.getCellStyle();

> 

>                   if(formatType == 1)

> 

>                         cellStyle.setDataFormat((short)1); 

> //Format -->

> "0"

> 

>                   else if(formatType == 4)

> 

>                         cellStyle.setDataFormat((short)4); 

> //Format -->

> "#,##0.00"

> 

>                   else if(formatType == 0xa)

> 

>                         cellStyle.setDataFormat((short)0xa); //Format

> --> "0.00%"

> 

>                   else if(formatType == 0x11)

> 

>                         cellStyle.setDataFormat((short)0xa); //Format

> --> "mmm-yy"

> 

>                   else

> 

>                         cellStyle.setDataFormat((short)0); 

> //Format -->

> General

> 

> 

> 

> 

> 

> I noticed that createCellStyle

> <file:///C:\Lukens\TVA\Jakarta%20-%20POI%201.5.1\poi-bin-2.0-p

re3-200307

28\docs\apidocs\org\apache\poi\hssf\usermodel\HSSFWorkbook.html#createCe

llStyle()> () and createDataFormat

<file:///C:\Lukens\TVA\Jakarta%20-%20POI%201.5.1\poi-bin-2.0-pre3-200307

28\docs\apidocs\org\apache\poi\hssf\usermodel\HSSFWorkbook.html#createDa

taFormat()> () API only available in the HSSFWorkbook class. If each

cell can have its own format and style, shouldn't these API be in

HSSFCell class?

 

 

 

 

 

Thanks in advance.

 

Prashant Patel

 

 

 

 

 

 

---------------------------------------------------------------------

To unsubscribe, e-mail: [EMAIL PROTECTED]

For additional commands, e-mail: [EMAIL PROTECTED]

 

Reply via email to