Reputation: 89
Excel downloaded from displaytag export option has a field of contact Number, and we have contact numbers ranging from 10 to 15 digits, (some prefixed by +
and others arent), in microsoft excel the column contact numbers shows the numbers in scientific format example : 9.20E+011
, where as I am looking for a way to display as it is (no matter if its in text form), any idea on the issue will help.
Thanks
Upvotes: 0
Views: 500
Reputation: 654
Often Excel tries to guess the best reprasentation for this data. And because the numbers are that "huge" it uses the scientific format. A simple solution could be to try to put the numbers into "quotation marks". Either directly by putting them in quotation marks or by converting the numbers into strings before addressing them in displaytag.
A more complex solution could be to use table decorators for the export, see this Tutorial.
There you can have your own implementation of TableDecorator
defined for the excel export and for your contact numbers you can define to use the HSSFRichTextString
to force Excel to interpret the number not as a number.
<display:table name="test" export="true" decorator="org.displaytag.sample.ModelTableDecorator" >
<display:setProperty name="decorator.media.excel" value="org.displaytag.sample.decorators.HssfTotalWrapper" />
...
</...>
You can find examples of these decorators in the src file displaytag-1.2-src.zip
Upvotes: 1