Author Topic: excel export error  (Read 2192 times)

mrha

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 5
    • View Profile
excel export error
« on: April 18, 2019, 02:31:39 pm »

The csv, html, and json context menus work fine, but the xlsx and xlsxMethod2 context menus fail.


Here is my exception message:
Quote

pqgrid.min.js:17 Uncaught TypeError: Cannot read property 'getFnW' of undefined
    at e.(anonymous function).(anonymous function)._pq.pqGrid.getFormula (http://127.0.0.1:5500/library/paramquery/pqgrid.min.js:17:12223)
    at e.cExport.getXlsBody (pqgrid.min.js:17)
    at e.cExport.getWorkbook (pqgrid.min.js:17)
    at e.cExport.Export (pqgrid.min.js:16)
    at e.(anonymous function).(anonymous function).n.exportData (http://127.0.0.1:5500/library/paramquery/pqgrid.min.js:16:26761)
    at e.(anonymous function).(anonymous function).exportFile (http://127.0.0.1:5500/public/paramquery_wrapper.js:332:25)
    at e.(anonymous function).(anonymous function).action (http://127.0.0.1:5500/public/paramquery_module.js:40:75)
    at e.cContext.onclickDoc (pqgrid.min.js:15)
    at HTMLBodyElement.dispatch (jquery.min.js:3)
    at HTMLBodyElement.v.handle (jquery.min.js:3)
_pq.pqGrid.getFormula @ pqgrid.min.js:17
getXlsBody @ pqgrid.min.js:17
getWorkbook @ pqgrid.min.js:17
Export @ pqgrid.min.js:16
n.exportData @ pqgrid.min.js:16
exportFile @ paramquery_wrapper.js:332
action @ paramquery_module.js:40
onclickDoc @ pqgrid.min.js:15
dispatch @ jquery.min.js:3
v.handle @ jquery.min.js:3


pqgrid.min.js:17 Uncaught TypeError: Cannot read property 'getFnW' of undefined
    at e.(anonymous function).(anonymous function)._pq.pqGrid.getFormula (http://127.0.0.1:5500/library/paramquery/pqgrid.min.js:17:12223)
    at e.cExport.getXlsBody (pqgrid.min.js:17)
    at e.cExport.getWorkbook (pqgrid.min.js:17)
    at e.cExport.Export (pqgrid.min.js:16)
    at e.(anonymous function).(anonymous function).n.exportData (http://127.0.0.1:5500/library/paramquery/pqgrid.min.js:16:26761)
    at e.(anonymous function).(anonymous function).action (http://127.0.0.1:5500/public/paramquery_module.js:45:49)
    at e.cContext.onclickDoc (pqgrid.min.js:15)
    at HTMLBodyElement.dispatch (jquery.min.js:3)
    at HTMLBodyElement.v.handle (jquery.min.js:3)
_pq.pqGrid.getFormula @ pqgrid.min.js:17
getXlsBody @ pqgrid.min.js:17
getWorkbook @ pqgrid.min.js:17
Export @ pqgrid.min.js:16
n.exportData @ pqgrid.min.js:16
action @ paramquery_module.js:45
onclickDoc @ pqgrid.min.js:15
dispatch @ jquery.min.js:3
v.handle @ jquery.min.js:3



Here is my code:

Code: [Select]

export class ParamQuery {

    exportFile(format) {

        let blob = this.exportData({ format: format });
        if (typeof blob === "string") {
            blob = new Blob([blob]);
        }
        saveAs(blob, "pqGrid." + format);
    }

}


export class PQContextMenu extends HelperBase {
    constructor(instance) {
        super(instance);
        this.on = true;
        this.head = true;
        this.items = this.getItems;
    }
    getItems(evt, ui) {
        return (ui.$th)
            ? []
            : [
                {
                    name: 'Export',
                    subItems: [
                        {
                            name: 'csv',
                            action: function () { this.wrapper.exportFile.call(this, "csv"); }
                        },
                        {
                            name: 'html',
                            action: function () { this.wrapper.exportFile.call(this, "html"); }
                        },
                        {
                            name: 'json',
                            action: function () { this.wrapper.exportFile.call(this, "json"); }
                        },
                        {
                            name: 'xlsx',
                            action: function () { this.wrapper.exportFile.call(this, "xlsx"); }
                        },
                        {
                            name: 'xlsxMethod2',
                            action: function () {
                                let blob = this.exportData({
                                    //url: "/pro/demos/exportData",
                                    format: "xlsx",
                                    nopqdata: false,
                                    render: true
                                });
                                if (typeof blob === "string") {
                                    blob = new Blob([blob]);
                                }
                                saveAs(blob, "pqGrid." + "xlsx");
                            }
                        }
                    ]
                },
                'separator',
                {
                    name: "Copy",
                    icon: 'ui-icon ui-icon-copy',
                    shortcut: 'Ctrl - C',
                    //tooltip: "Works only for copy / paste within the same grid",
                    action: function () {
                        this.copy();
                    }
                },
                {
                    name: "Paste",
                    icon: 'ui-icon ui-icon-clipboard',
                    shortcut: 'Ctrl - V',
                    //disabled: !this.canPaste(),
                    action: function () {
                        this.paste();
                        //this.clearPaste();
                    }
                },
            ];
    }
}

reference link = > https://paramquery.com/pro/demos/context_menu

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6124
    • View Profile
Re: excel export error
« Reply #1 on: April 18, 2019, 09:57:38 pm »
There is no such error in the demo. Could you please share a jsfiddle to reproduce the error.