Hi,
I'm posting to report I solved my problem by extending org.displaytag.export.excel.ExcelHssfView. I modified the lines in the doExport method that create the cells to explicitly set the cell type, like below:
if(value instanceof String)
{ cell.setCellType(HSSFCell.CELL_TYPE_STRING); } if(value == null){ cell.setCellType(HSSFCell.CELL_TYPE_BLANK); }else{ if (value instanceof Number) { Number num = (Number) value; cell.setCellValue(num.doubleValue()); } else if (value instanceof Date) { cell.setCellValue((Date) value); } else if (value instanceof Calendar) { cell.setCellValue((Calendar) value); } else { cell.setCellValue(escapeColumnValue(value)); } } Of course, I also referenced my new class in displaytag.properties as export.excel.class so that this class would be used instead of the default view.
I'm not sure if the type was being deliberately left unset so that numeric data masquerading in a String object would be converted by Excel or not, nor was I sure whether this was worthy of a patch to the default Excel exporting view or not. It solved my particular problem, and wanted to post in case others were dealing with the same issues.
Thanks
Todd Farmer
From: [EMAIL PROTECTED] on behalf of Farmer, Todd Sent: Wed 7/12/2006 11:07 AM To: displaytag-user@lists.sourceforge.net Subject: [displaytag-user] Controlling Excel Formatting in Exports Hi,
I’ve finally got my export processing working (thanks, Jorge!). Now for the next obstacle – retaining formatting within Excel. Specifically, I have zero-padded numeric values that are represented in the domain objects as Strings. When they are exported to Excel, the leading zeros are truncated, as is Excel’s custom for dealing with numeric data. Is there any DisplayTag-centric way to control this? I can’t find any documentation that suggests that it is, but it must be an issue that others have addressed previously. I’d appreciate any insight anyone has.
Thanks! Todd Farmer |
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ displaytag-user mailing list displaytag-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/displaytag-user