Unable to set cell type to numeric

UI Components for JSF
Post Reply
XCDemon
Posts: 4
Joined: 16 Jul 2010, 20:13

01 Sep 2010, 20:23

I'm using primefaces 1.1.RC1 and POI 3.2-Final in my application. I am using the dataexporter to export an xls. I've been able to format the fields
in a certain column that are currency fields successfully in the postProcessor, however when the xls opens it is still treating the values as text. Once I double click in any of the cells the value swaps out for the formatted numeric currency format.

For example when I first open the xls the value is 75, once I double click the value changes to $75.00.

I've tried to set the cellType to numeric with

cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);

however this always throws an exception with the message java.lang.IllegalStateException: Cannot get a numeric value from a text cell
I'd like for the spreadsheet to already display the values in the correct format and type. I'm really confused by the behavior that the spreadsheet appears to have the right formatting in it, but only displays it once the cell has been double clicked
Any help or direction would be greatly apprecieated.

XCDemon
Posts: 4
Joined: 16 Jul 2010, 20:13

07 Sep 2010, 17:55

I was able to resolve this by what seems like a workaround for me, but works at least.
The following will take the existing value in the cell and set it as a Double which means
the exported xls will open with the correct numeric format on the fields.

Code: Select all

			//setting the value to a Double value of the original results in the type being numeric
			cell.setCellValue(new Double(cell.getRichStringCellValue().getString()));			

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 26 guests