/** * Return the numeric value. * * @param cell the cell to extract the value from. * @return the numeric value from the cell. */ private static String getNumericValue(Cell cell, CellValue cellValue, boolean fromFormula) { // Date is typed as numeric if (HSSFDateUtil.isCellDateFormatted(cell)) { // TODO configurable?? DateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH); return sdf.format(cell.getDateCellValue()); } // Numeric type (use data formatter to get number format right) DataFormatter formatter = new HSSFDataFormatter(Locale.ENGLISH); if (cellValue == null) { return formatter.formatCellValue(cell); } return fromFormula ? cellValue.formatAsString() : formatter.formatCellValue(cell); }
/** * Creates a format tracking wrapper around the given listener, using * the given locale for the formats. * * @param childListener the listener to be wrapped * @param locale the locale for the formats */ public FormatTrackingHSSFListenerPlus( HSSFListener childListener, Locale locale) { _childListener = childListener; _formatter = new HSSFDataFormatter(locale); _defaultFormat = NumberFormat.getInstance(locale); }