poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 52684] New: Reading Numeric Cell Values with Custom Formats
Date Thu, 16 Feb 2012 16:04:11 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=52684

             Bug #: 52684
           Summary: Reading Numeric Cell Values with Custom Formats
           Product: POI
           Version: 3.8-dev
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: tcole6@gmail.com
    Classification: Unclassified


I am unable to read a formatted numeric value that has a custom format.

Example:

In Excel 2007, enter value 12312345123 in a cell.

Format the cell with a custom format of 000-00000-000.

The cell now contains the formatted value 123-12345-123.

>From POI read the contents of the cell using:

[code]
//load Workbook as workbook...
DataFormatter formatter = new DataFormatter();
FormulaEvaluator evaluator =
workbook.getCreationHelper().createFormulaEvaluator();
//obtain Cell as cell...
if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
     if (cell.getCachedFormulaResultType() == Cell.CELL_TYPE_ERROR) { 
          data[i][j] = "#VALUE!"; 
     } 
     else { 
          data[i][j] = formatter.formatCellValue(cell, evaluator); 
     }
}
else {
     data[i][j] = formatter.formatCellValue(cell);
}

This sets data[i][j] to "12312345123"

Running the following on the cell returns:

cell.getCellStyle().getDataFormatString() returns "000\-00000\-000"
cell.getCellStyle().getDataFormat() returns 164

These values are correct and indicate that the format is loaded, but is not
applied properly to the "formatted" output.

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message