Grid xlsx saveAsync error

Posted by: deepakdaash on 21 April 2018, 9:21 am EST

  • Posted 21 April 2018, 9:21 am EST

    I get an error when i try to save the grid to excel.

    JSZip is not a constructor

    at Function.e._saveWorkbookToZip (wijmo.xlsx.js?78ca:13)

    at Function.e.saveAsync (wijmo.xlsx.js?78ca:13)

    at e.saveAsync (wijmo.xlsx.js?78ca:13)

    at Function.e.saveAsync (wijmo.grid.xlsx.js?9386:13)

    
    
    VueJS2 class components (lang=ts)
    
    import JSZip from 'jszip'; //main.ts
    
    //webpack
     alias: {
            jszip: 'jszip/dist/jszip.min.js'
        },
    
    
    //component
        wjXls.FlexGridXlsxConverter.saveAsync(this.GridInstance, { includeColumnHeaders: true, includeCellStyles: false }, 'file.xlsx');
    
    
    //package.json
        "jszip": "^3.1.5",
        "script-loader": "^0.7.2",
    
    
    
    

    I am perfectly able to user JSZip despite the error. To test if my import is working ive created a zip file and it gets downloaded when i visit the component.

    
    
    created(){
    	 var zip:any = new JSZip();
         zip.generateAsync({type:"base64"}).then(function (base64:any) {
            window.location.href = "data:application/zip;base64," + base64;
        });
    }
    
    
    
  • Posted 22 April 2018, 9:12 pm EST

    Hi,

    The error throws because of JSZip is not assigned to window object.

    Please try to add JSZip in your main/index page using tag and let us know if you still face any issues.

    ~Manish

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels