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

            Bug ID: 69701
           Summary: Formatting silently lost when updating POI:
                    DATA_FORMAT & WRAP_TEXT missing from namePropertyMap
           Product: POI
           Version: 5.4.1-FINAL
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: POI Overall
          Assignee: dev@poi.apache.org
          Reporter: wfa...@gmail.com
  Target Milestone: ---

When calling this deprecated method in org.apache.poi.ss.util.CellUtil:

public static void setCellStyleProperty(Cell cell, String propertyName, Object
propertyValue) {
    setCellStyleProperty(cell,
(CellPropertyType)namePropertyMap.get(propertyName), propertyValue);
}

with a propertyName value of CellUtil.DATA_FORMAT or CellUtil.WRAP_TEXT, it
does not delegate to the new method that replaces it because neither
CellUtil.DATA_FORMAT nor CellUtil.WRAP_TEXT exist in the map named
'namePropertyMap'.

I believe this can be fixed by adding the missing properties to the map. I am
more certain it will work for DATA_FORMAT as calling the new method (with
CellPropertyType.DATA_FORMAT) works. I did not try WRAP_TEXT, but I did notice
it was also missing from the map. 

Issue for POI users:

When developers update from lower versions of POI (e.g., 5.2.3) to 5.4.1 (and
probably some prior versions) calling the old method, DATA_FORMAT and WRAP_TEXT
are silently ignored. In my case, dates previously formatted m/d/yyyy came back
formatted as Excel serial dates (e.g., 45805). Because it fails silently, you
will only know that something went wrong when you notice the format is wrong in
the Excel file produced.

For a developer to fix this, update all calls to the deprecated method and call
the new method instead. Here is the signature (notice arg 2 is CellPropertyType
enum): 

setCellStyleProperty(Cell cell, CellPropertyType property, Object
propertyValue).

In practice, this most likely involves replacing all occurrences of
CellUtil.DATA_FORMAT and CellUtil.WRAP_TEXT in your code with
CellPropertyType.DATA_FORMAT and CellPropertyType.WRAP_TEXT, respectively. You
will also need to update the related import statements.

-- 
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