Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Force column types when exporting to Excel

    We are using SmartgwtPro 4.1 and we have problem when exporting to Excel because some string columns are interpreted as numeric values in Excel.
    As one of 4.1 features is "Force column types: prevents Excel from interpreting string values as numeric or date values because they happen to look that way", is there something we need to set to enable such behaviour?

    #2
    Nothing special; it happens automatically when the field is declared as type "string" or "text" (or a derived type).

    If it's not happening for you, we need a way to reproduce the issue.

    Comment


      #3
      It is not happening in our case. The field is declared in *.ds.xml as (we use JPA2DataSource):
      Code:
      <field name="fromAccount" type="string">
              <title><fmt:message key="order_from_account"/></title>
      </field>
      In database table this field is declared as VARCHAR, in entity class this property is also String. In ListGrid we have field for this property declared as:
      Code:
      ListGridField fromAccount = new ListGridField("fromAccount", messages.order_from_account(), 120);
      In ListGrid values for this field are displayed correctly. We are exporting to Excel using this code:
      Code:
      DSRequest dsRequestProperties = new DSRequest();  
      dsRequestProperties.setExportAs(ExportFormat.XLS);  
      dsRequestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
      exportData(dsRequestProperties);
      One important thing: Values in fromAccount are strings that contains 16 digits (no other characters). Values that are exported to Excel are not only formatted incorrectly, but also incorrect. For example, in for value in list grid: 3060510000021818, (which is correct value), Excel displays 3.06051E+15, and the value that is stored in cell is 3060510000021820.

      If you need some other info to reproduce this, please let me know. I have already changed my code to avoid this problem by formatting fromAccount as "306-05100000218-18", but if you need more details I could switch bact to old code to reproduce this.

      Comment

      Working...
      X