Search code examples
excelapache-poixssf

How to get the cell unformatted value in POI XSSF event model?


cell A1 has the formula "=A2" and is formatted to show 1 decimal point

cell A2 has the value 4.23

cell A1 shows 4.2 (formatted display value)

cell A2 shows 4.23 (formatted display value)

My XSSF eventmodel sheetContentHandler class implements

public void cell(String cellReference, String formattedValue, XSSFComment comment)

but formattedValue returns 4.2 for cell A1, and i want to retrieve the unformattedValue 4.23

How can i do this ? (I can't change to usermodel, i have huge files)


Solution

  • Ok There is no way to do this using the sheetContentHandler (though you could get the actual formula if you want there, but that is not what i am looking for)

    The only solution will be to use a SheetHandler class which extends DefaultHandler.

    Example code on apache-poi site: Example