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

Invalid formulas cause data coruption in Excel export formats

$
0
0
SmartClient: v10.0p_2015-06-23
Browser: Chrome

When exporting a grid with an invalid formula, the Excel spreadsheets (97 and OOXML) are currupted and will not open with all data. Exporting to JSON shows the new formula column as "NA", as it should in Excel.

Test steps:
- load test case
- execute command in console "exportXLSOOXML()"
- observe spreadsheet is loaded correctly
- create a formula column "AB"
- observe field values are "NA"
- execute command in console "exportXLSOOXML()"
- observe that Excel complains about the file and does not load all records.



Code:

<!DOCTYPE html>

<html>
        <head>

                <title></title>
               
                <style>
                        .diagInfo {
                                font-size: 14px;
                                font-weight: bold;
                                padding: 5px;
                        }
                </style>
               
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Core.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Foundation.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Containers.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Grids.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Forms.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_DataBinding.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Drawing.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_PluginBridges.js"></script>
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Charts.js"></script>       
                <script type="text/javascript" SRC="http://localhost:8080/isomorphic/skins/EnterpriseBlue/load_skin.js"></script>
       
                <script type="text/javascript" >
                        var isomorphicDir="http://localhost:8080/isomorphic/";
                       
                        // set this to the correct JIRA ticket
                        var JIRA_TICKET = "SNQA-652";
                       
                        // test data
                        var data = [
                                {inspectorID:12345, region:"Northeast", inspections:206, observations:913,lastInspectionDate:new Date(2012, 8, 13), index:52.6 },
                                {inspectorID:67890, region:"West", inspections:66, observations:2,lastInspectionDate:new Date(2013, 2,2), index:75.3 },
                                {inspectorID:54321, region:"Northeast", inspections:4, observations:67,lastInspectionDate:new Date(2013,2,3), index:75.3 },
                                {inspectorID:09876, region:"South", inspections:24, observations:0,lastInspectionDate:new Date(2012,8,31), index:52.6 }
                        ];
                        // datasource for the grid               
                        isc.DataSource.create({
                                ID: "ds",
                                fields: [
                                        {name:"inspectorID", title:"Inspector ID", type:"integer", showIf:"false" }, // hidden
                                        {name:"inspections", type:"integer", title:"Number of Inspections Total"},
                                        {name:"observations", title:"# Observations"},
                                        {name:"region", type:"text", title:"Region/Country"},
                                        {name:"lastInspectionDate", type:"date", title:"Last Inspection"}
                                ],
                                cacheData:data,
                                clientOnly: true
                        });
                       
                        // once page loads set some diagnostic information, DO NOT CHANGE
                        isc.Page.setEvent("load", function() {
                                document.title = JIRA_TICKET + "  (SmartClient version " + isc.versionNumber + ")";
                                var html = [];
                                html.push("Jira: " + JIRA_TICKET);
                                html.push("SmartClient: " + isc.versionNumber);
                                html.push("Browser: " + navigator.appCodeName + " " + navigator.appName + " " + navigator.appVersion);
                                diagLabel.setContents( html.join("<br>"));
                        });
                       
                        // some utility functions
                       
                        var exportXLS = function() {
                                grid.exportClientData({
                                                exportAs : "xls",
                                                exportDisplay : "download",
                                                exportFilename : JIRA_TICKET + ".xls"
                                        })
                        }
                       
                        var exportPDF = function() {
                                var settings = {        skinName : "EnterpriseBlue",
                                                                        pdfName : JIRA_TICKET
                                };
                                isc.RPCManager.exportContent(layout, settings);
                        }
                       
                        var printPreview = function() {
                                Canvas.showPrintPreview(grid, {}, {
                                                canDragResize : true,
                                                width : "50%",
                                                height : "50%",
                                                autoCenter : true,
                                                title : JIRA_TICKET + "Print Preview"
                                        } );
                        }
                </script>

        </head>
       
        <body>
                <script>
               
                        // ===== DO NOT REMOVE =====
                        var diagLabel = isc.Label.create({
                                                ID: "diagInfo",
                                                width: "100%",
                                                styleName: "diagInfo",
                                                autoFit: true
                                        });
                        // ===== DO NOT REMOVE =====
                                               
                        // basic grid               
                        var grid = isc.ListGrid.create({
                                dataSource: ds,
                                dataFetchMode : "local",
                                autoFetchData: true,
                                clientOnly: true,
                                position: "relative",
                                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,
                                badFormulaResultValue: "NA"
                        });       
                       
                        // the main page layout - place all other components afetr diagLabel
                        var layout = isc.VLayout.create({
                                width:"100%",
                                membersMargin: 20,
                                members: [
                                        // ===== DO NOT REMOVE diagLabel
                                        diagLabel,
                                        // ===== place anty components here
                                        grid
                                ]
                        });
                       
                        var exportJSON = function() {
               
                        var exportOpts = {
                                                exportAs : "json",
                                                exportDisplay : "download",
                                                exportFilename : "SNQA-661.json",
                                                message : "JSON"
                                        };
                        grid.exportClientData(exportOpts);               
                }
                       
                var exportXML = function() {
               
                        var exportOpts = {
                                                exportAs : "xml",
                                                exportDisplay : "download",
                                                exportFilename : "SNQA-661.xml",
                                                message : "XML"
                                        };
                        grid.exportClientData(exportOpts);               
                }
                var exportXLS97 = function() {
               
                        var exportOpts = {
                                                exportAs : "xls",
                                                exportDisplay : "download",
                                                exportFilename : "SNQA-661.xls",
                                                message : "XLS"
                                        };
                        grid.exportClientData(exportOpts);               
                }
                var exportXLSOOXML = function() {
               
                        var exportOpts = {
                                                exportAs : "xls",
                                                exportDisplay : "download",
                                                exportFilename : "SNQA-661.xls",
                                                message : "XLS"
                                        };
                        grid.exportClientData(exportOpts);               
                }
                               
                </script>

        </body>

</html>


Viewing all articles
Browse latest Browse all 4756

Trending Articles