https://issues.apache.org/bugzilla/show_bug.cgi?id=52421
Yegor Kozlov <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |WONTFIX --- Comment #1 from Yegor Kozlov <[email protected]> 2012-01-14 17:46:15 UTC --- This is expected behavior. POI delegates formatting of numbers to java.text.DecimalFormat and this class does not support automatic switching to scientific notation. Explicitly set a exponential format and you will be good: Workbook wb = new HSSFWorkbook(); // create a cell style that formats numbers in scientific notation CellStyle style = workbook.createCellStyle(); int idx = workbook.getCreationHelper().createDataFormat().getFormat("##0.0E+0"); style.setDataFormat((short)idx); double[] values = {1, 1e12, 1e32, 1e64}; Sheet sheet = wb.createSheet(); Row row = sheet.createRow(0); for (int c = 0; c < values.length; c++) { Cell cell = row.createCell(c); cell.setCellValue(values[c]); cell.setCellStyle(style); sheet.autoSizeColumn(c); System.out.println("column width /256 = " + sheet.getColumnWidth(c) / 256); } Yegor -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
