Basic Excel currency format with Apache POI

After digging through the documentation a bit more, I found the answer:

http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFDataFormat.html

Just need to find an appropriate pre-set format and supply the code.

    styleCurrencyFormat.setDataFormat((short)8); //8 = "($#,##0.00_);[Red]($#,##0.00)"

Here are more examples:
http://www.roseindia.net/java/poi/setDataFormat.shtml

Leave a Comment