java - Write number in excel cells using Apache POI -


How can I write my full value in cell with the help of Power?

i.e. If the price is 1000.000, how can I write without loosing 000 000 without any integer "." With PoI? This means that I need full value.

In my case, it only takes 1000 but this is not the right form for me.

You have to set the "format" of the cell, where this number is being stored. Example code:

  workbook wb = new HSSFWorkbook (); Sheet sheet = wb.createSheet ("format sheet"); Cell style style; Data Format Format = wb.createDataFormat (); Line line; Cell cell; Small line = 0; Small colNum = 0; Line = sheet.createRow (rowNum ++); Cell = row.createCell (colNum); Cell.setCellValue (11,111.25); Style = wb.createCellStyle (); Style.setDataFormat (format.getFormat ("0.0")); Cell.setCellStyle (style); Line = sheet.createRow (rowNum ++); Cell = row.createCell (colNum); Cell.setCellValue (11,111.25); Style = wb.createCellStyle (); Style.setDataFormat (format.getFormat ("#, ## 0.0000")); Cell.setCellStyle (style); FileOutputStream fileOut = New FileOutputStream ("workbook.xls"); Wb.write (fileOut); FileOut.close ();   

Source:

Comments