You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2025/05/30 01:59:56 UTC
[Bug 69701] New: Formatting silently lost when updating POI: DATA_FORMAT & WRAP_TEXT missing from namePropertyMap
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: wfairc@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-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 69701] Formatting silently lost when updating POI: DATA_FORMAT & WRAP_TEXT missing from namePropertyMap
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69701
PJ Fanning <fa...@yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #1 from PJ Fanning <fa...@yahoo.com> ---
Fixed by
https://github.com/apache/poi/commit/9a4a4270eca7e0b4fae40a9d1b47272c8b524010
--
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
[Bug 69701] Formatting silently lost when updating POI: DATA_FORMAT & WRAP_TEXT missing from namePropertyMap
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69701
--- Comment #2 from wfairc@gmail.com ---
Thanks PJ! That was fast!
--
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