https://bz.apache.org/bugzilla/show_bug.cgi?id=60422

            Bug ID: 60422
           Summary: DataFormatter.formatCellValue retunrs incorrect value
                    for german 'Buchhaltung' format
           Product: POI
           Version: 3.15-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
          Assignee: dev@poi.apache.org
          Reporter: r...@rbri.de
  Target Milestone: ---

Created attachment 34481
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34481&action=edit
the input file

I have some code that tries to reproduce the visible values of a spreadsheet.
So i made a small test sheet with cells using different formats.
Works fine so far.

But starting with version 3.14 i got strange results for one cell.

The cell is formatted as 'Buchhaltung' (see screenshot).
The (visible) value of the cell is '4,33 €' in excel and '0,004,,33.00 €' when
using poi.

My code is this / the locale used is Locale.GERMAN:

  /**
   * Reads the content of an excel cell and converts it into the string
   * visible in the excel sheet.
   *
   * @param aRow the row
   * @param aColumnsNo the column
   * @param aFormulaEvaluator the formula Evaluator
   * @param aLocale used for parsing and formating
   * @return the display string
   */
  public static String readCellContentAsString(final Row aRow, final int
aColumnsNo,
      final FormulaEvaluator aFormulaEvaluator, final Locale aLocale) {
    final Cell tmpCell = aRow.getCell(aColumnsNo);
    if (null == tmpCell) {
      return null;
    }

    final DataFormatter tmpDataFormatter = new DataFormatter(aLocale);
    try {
      final String tmpResult = tmpDataFormatter.formatCellValue(tmpCell,
aFormulaEvaluator);
      return tmpResult;
    } catch (final NotImplementedException e) {
      final StringBuilder tmpMsg = new StringBuilder(e.getMessage());
      if (null != e.getCause()) {
        tmpMsg.append(" (");
        tmpMsg.append(e.getCause().toString());
        tmpMsg.append(')');
      }
      LOG.error(tmpMsg.toString());
      final String tmpResult = tmpDataFormatter.formatCellValue(tmpCell, null);
      return tmpResult;
    }
  }

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to