<Br/> hssfworkbook workbook = new hssfworkbook (); <br/> hssfsheet sheet = workbook. createsheet ("sheet1"); <br/> hssfrow ROW = sheet. createrow (0); <br/> hssfcell cell = row. createcell (0); <br/> hssfcellstyle currencystyle = workbook. createcellstyle (); <br/> currencystyle. setdataformat (short) 4); <br/> cell. setcellstyle (currencystyle); <br/>
The format of the number following setdataformat is as follows:
0, "general" <br/> 1, "0" <br/> 2, "0.00" <br/> 3 ,"#, #0 "<br/> 4," #,## 0.00 "<br/> 5," $ #, #0 _); ($ #, #0) "<br/> 6," $ #, #0 _); [Red] ($ #, #0) "<br/> 7, "$ #, #0.00); ($ #, #0.00)" <br/> 8, "$ #, #0.00 _); [Red] ($ #, #0.00) "<br/> 9," 0% "<br/> 0xa," 0.00% "<br/> 0xb, "0.00e + 00" <br/> 0xc ,"#? /? "<Br/> 0xd ,"#?? /?? "<Br/> 0xe," m/D/YY "<br/> 0xf," d-mmm-yy "<br/> 0x10, "D-Mmm" <br/> 0x11, "Mmm-yy" <br/> 0x12, "H: mm am/PM "<br/> 0x13," H: mm: ss am/PM "<br/> 0x14," H: MM "<br/> 0x15," H: mm: SS "<br/> 0x16," m/D/yy h: MM "</P> <p> // 0x17-0x24 reserved for international and unformatted ented 0x25," #, #0 _);(#, #0) "<br/> 0x26," #, #0 _); [Red] (#, #0) "<br/> 0x27," #,## 0.00 _); (#,## 0.00) "<br/> 0x28 ,"#, #0.00 _); [Red] (#, #0.00) "<br/> 0x 29, "_ (* #, #0 _); _ (* (#, #0 );_(*/"-/"_); _ (@ _) "<br/> 0x2a," _ ($ * #, #0 _); _ ($ * (#, #0 ); _ ($ */"-/" _); _ (@ _) "<br/> 0x2b," _ (* #,## 0.00 _); _ (* (#, #0.00 );_(*/"-/"?? _); _ (@ _) "<Br/> 0x2c," _ ($ * #, #0.00 _); _ ($ * (#, #0.00 ); _ ($ */"-/"?? _); _ (@ _) "<Br/> 0x2d," Mm: SS "<br/> 0x2e," [H]: mm: SS "<br/> 0x2f," Mm: ss.0 "<br/> 0x30," # 0.0e + 0 "<br/> 0x31, "@"-This is text format. <br/> 0x31 "text"-alias for "@" <br/>