Announcement

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

    SmartGWTEE 12.0p -- Max Length Exception with ListGrid OOXML export

    isc Version: v12.0p_2019-08-11/Enterprise Deployment
    GWT Version: 2.7.0
    Browser: Chrome 76.0.3809.100 (Official Build) (64-bit
    OS: Windows 10
    SuperDevMode

    Hi, I am running into an error exporting a ListGrid to Excel when the grid contains fields that are too long to fit in an Excel cell (the max length in Excel is 32,767 characters). The export does not outright fail or display an error, but the exported file is an unformatted, incomplete result set that ends at the problematic cell. Below are the steps to reproduce my issue in the built-in-ds sample project.

    Setup Steps

    1. Modify /war/WEB-INF/db/hsqldb/isomorphic.script

    In the animals table declaration on line 71, replace "INFORMATION VARCHAR(1000)" with "INFORMATION VARCHAR(50000)"

    2. Modify /war/ds/animals.ds.xml

    In the information field definition on line 22, set length="50000"

    3. Modify /src/com/smartgwt/sample/client/BuiltInDS.java

    Add an export button to the form at line 171

    Code:
    IButton exportBtn = new IButton("Export");
    exportBtn.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            DSRequest requestProperties = new DSRequest();
            requestProperties.setExportAs(ExportFormat.OOXML);
            boundList.exportClientData(requestProperties);
        }
    });
    hLayout.addMember(exportBtn);
    Test Steps
    1. Start the server and select the Animals DataSource
    2. Edit the Alligator record and set "Interesting Facts" to a string longer than 32767 characters.
    3. Save the animal record.
    4. Click export.
    Click image for larger version  Name:	export_animals.jpg Views:	1 Size:	222.9 KB ID:	259008

    Results
    Click image for larger version  Name:	excel_export.jpg Views:	1 Size:	34.0 KB ID:	259009

    The file is exported, but only contains one row (everything up to the Interesting Facts cell)
    A stack trace is displayed in the server console:

    Code:
    java.lang.IllegalArgumentException: The maximum length of cell contents (text) is 32,767 characters
    at org.apache.poi.xssf.streaming.SXSSFCell.setCellValue(SXSSFCell.java:325)
    at com.isomorphic.rpc.ExcelDataExport.getExportObject(ExcelDataExport.java:877)
    at com.isomorphic.rpc.DataExport.exportResultSet(DataExport.java:642)
    at com.isomorphic.rpc.DataExport.exportResultSet(DataExport.java:452)
    at com.isomorphic.rpc.BuiltinRPC.downloadClientExport(BuiltinRPC.java:1139)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    ...
    I know the data being exported is incompatible and so the export should fail in some way, but I am not sure if this particular outcome is expected or not. Or is there something I should be doing in the export request itself (maybe in the requestProperties) to ensure the offending data is truncated or excluded?

    Thanks!
    Last edited by jbrasee_iqs; 13 Aug 2019, 05:16.

    #2
    I was able to work around this issue by extending the IDACall servlet and overriding handleDSRequest() to loop through the DSResponse data and truncate fields as needed before sending off the response for export. (Note that this is for a server-side export, so it may not be entirely applicable to the exportClientData example given in my original post.)

    Code:
    @Override
    public DSResponse handleDSRequest(DSRequest req, RPCManager rpc, RequestContext reqContext) throws Exception {
        DSResponse resp = super.handleDSRequest(req, rpc, reqContext);
    
        if(ExportFormat.OOXML.toString().equalsIgnoreCase(req.getExportAs()))
        {
            //loop through records from resp.getDataList() and truncate long field values
        }
        return resp;
    }
    Last edited by jbrasee_iqs; 19 Aug 2019, 06:23.

    Comment


      #3
      This is fixed and will be available for download in nightly builds since Oct 4.

      Comment

      Working...
      X