]
Marek Novotny closed JBSEAM-3879.
---------------------------------
Fix Version/s: 2.2.0.GA
Resolution: Done
closing due latest comments about fixed status in 2.2.0.GA
e:cell formatting of date or number colum fails, if first value is a
null value
-------------------------------------------------------------------------------
Key: JBSEAM-3879
URL:
https://issues.jboss.org/browse/JBSEAM-3879
Project: Seam 2
Issue Type: Sub-task
Components: Excel
Affects Versions: 2.1.1.GA
Environment: Seam 2.1.1.GA, Windows, Jetty
Reporter: Alexander Schwartz
Assignee: Nicklas Karlsson
Labels: excel, null
Fix For: 2.2.0.GA
Attachments: jxlhelper.java.patch
The cell style of a e:cell is cached (for the specific id) when it is accessed for the
first time. When the first value is a null value, uiCell.getDataType() is unable to
automatically detect the data type of the column and returns 'general'. This is
then cached.
All other columns are then treated as 'general' in createCell(), and all data is
converted using data.toString() leading to ugly results.
Our solution is to add "xls-force-type: date" to all e:cell of type number or
date. We added this to the evaluation (see below).
Another idea would have been to defer caching until the first non-null value has been
met. But this might cause troubles in createCell() when there is a handing depending on
the type.
from JXLHelper.java:
/**
* Gets the cell type for a cell. Tries to look it up in a cache based on the
* component id of the cell. If it's not found, it's created and cached.
*
* @param uiCell The cell to look up
* @return The data type of a cell
*/
private CellType getCellDataType(UICell uiCell)
{
if (log.isTraceEnabled())
{
log.trace("Getting cell data type from cache for #0",
uiCell.getId());
}
CellType cellDataType = cellInfoCache.getCachedCellType(uiCell.getId());
if (cellDataType == null)
{
/* old code:
cellDataType = uiCell.getDataType();
*/
/* new code start */
CellStyle cellStyle = new CellStyle(parser.getCascadedStyleMap(uiCell));
cellDataType = cellStyle.forceType != null ? CellType
.valueOf(cellStyle.forceType) : uiCell.getDataType();
/* new code end */
cellInfoCache.setCachedCellType(uiCell.getId(), cellDataType);
}
return cellDataType;
}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: