Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

9.1 Regression: Cannot export XLS with formula fields containing a hidden field

$
0
0
SmartClient_v91p_2014-03-20_PowerEdition

This is not necessarily a regression, its more of a bug with new functionality. However, from the user persepctive it is a rgression, since it affects functionality that was working prior to 9.1.

I see that in 9.1 the XLS export now carries across the actual formula instead of the value of the formula in the sheet. When a formula contains a field that is hidden in the grid, the Excel throws an error about data being lost, most likely because it cannot find the referenced column. The following test case shows this issue:
- load test case
- observe that the inspectorID field is hidden, and the formula field is the inspectorID field/5. Formula field displays values.
- click export button
- Observe Excel opens and displays an error, no data is displayed
- Add the inspectorID field to the grid with the column picker.
- Click export again
- Observe data is displayed in Excel

This happens with multiple versions of Office. One solution is to force the hidden columns to be visible if they are included in a formula. I can do this as a workaround if needed but wanted to share this with you as well.

Code:

<!DOCTYPE html>

<html>
<head>
<style tyle="text/css">
<!--
@page {
  size: landscape;
 
}
-->
</style>

    <title >SNQA-426</title>
       
          <script type="text/javascript" >
                var isomorphicDir="http://localhost:8080/isomorphic/";
               
                var data = [
                        {inspectorID:12345, region:"United States", state:"Pennsylvania", city:"Pittsburgh", inspections:206,observations:913,lastInspectionDate:new Date(2012, 8, 13),index:52.6, inspectionType: {id:123, name:"type1"}},
                        {inspectorID:67890, region:"United States", state:"Pennsylvania", city:"Butler", inspections:66,observations:0,lastInspectionDate:new Date(2013, 2,2),index:75.3, inspectionType: {id:123, name:"type1"}},
                        {inspectorID:88776, region:"United States", state:"Pennsylvania", city:"Pittsburgh", inspections:66,observations:67,lastInspectionDate:new Date(2013,2,3),index:75.3, inspectionType: {id:123, name:"type1"}},
                        {inspectorID:44556, region:"United States", state:"Pennsylvania", city:"Philadelphia", inspections:206,observations:0,lastInspectionDate:new Date(2012,8,31),index:52.6, inspectionType: {id:123, name:"type1"}}
                ];
</script>
       
 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Core.js"></script>
 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Foundation.js"></script>
 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Containers.js"></script>
  <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Grids.js"></script>
 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Forms.js"></script>
 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_DataBinding.js"></script>
 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Drawing.js"></script>
 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_PluginBridges.js"></script>
 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Charts.js"></script>
 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Tools.js"></script>
 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/skins/EnterpriseBlue/load_skin.js"></script>
       
</head>
<body>

        <br><br>
        <script>
       
                        isc.DataSource.create({
                                ID: "ds",
                                fields: [
                                        {name:"inspectorID", title:"Inspector ID", type:"integer", showIf:"false" },
                                        {name:"formula", title:"Formula",  userFormula: { formulaVars: { A: "inspectorID" }, text:"A/5"} },
                                        {name:"inspections", type:"integer", title:"Number of Inspections"},
                                        {name:"static", type:"text", title:"Really Long Static Field Title"},
                                        {name:"region", type:"text", title:"Region/Country"},
                                        {name:"state", type:"text", title:"State"},
                                        {name:"city", type:"text", title:"City/Municipality"},
                                        {name:"observations", title:"# Observations"},
                                        {name:"lastInspectionDate", type:"date", title:"Last Inspection"}
                                ],
                                cacheData:data,
                                clientOnly: true
                        });
                       
                        var gridObject = isc.ListGrid.create({
                                dataSource: ds,
                                dataFetchMode : "local",
                                autoFetchData: true,
                                clientOnly: true,
                                width : "100%",
                                align : "center",
                                autoFitData : "vertical",
                                autoFitMaxHeight : 400,
                                alternateRecordStyles : true,
                                canAddFormulaFields : true,
                                canAddSummaryFields : true,
                                canGroupBy : true,
                                canReorderFields : true,
                                showGroupSummary : true,
                                groupByMaxRecords : 5,
                                useAdvancedFieldPicker: true,
                                advancedFieldPickerThreshold: 5,
                                autoDraw:false
                        });       
                       
                        isc.VLayout.create({
                                width:"100%",
                                members: [
                                        gridObject,
                                        isc.Button.create({
                                                title:"Export",
                                                click: function() {
                                                        gridObject.exportClientData({
                                                                exportAs : "xls",
                                                                exportDisplay : "download",
                                                                exportFilename : "SNQA-426.xls"
                                                        })
                                                }       
                                        })
                                ]
                        });
                       
        </script>
        <br><br>

</body>

</html>


Viewing all articles
Browse latest Browse all 4756

Trending Articles