Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated zip file doesn't unzip to reveal an excel file #58

Open
squirrelsRduck opened this issue Apr 9, 2016 · 2 comments
Open

Generated zip file doesn't unzip to reveal an excel file #58

squirrelsRduck opened this issue Apr 9, 2016 · 2 comments

Comments

@squirrelsRduck
Copy link

I'm using Macintosh El Capitan. I sent a zipped excel spreadsheet from the generate function's buffer, and i receive in browser. I unzip, and there's just a folder in there, with all the necessary data. But, the wrong format. It's a folder, that I cannot seem to open in Excel. Interestingly, I notice the Excel object that the 'save' method performs also generates a folder-like object in the filesystem. Not sure if it's the way Macintosh unzips files, or if it's a bug with the zip utility in 0.1.0 of this module. anybody know how to correct this?

@squirrelsRduck
Copy link
Author

this might be something to look into: client side utilization of the zip utility.

though, i had wanted to use the HTML5 download attribute to simply access the file as such. does anybody have sample code as to how to download a file without the HTML5 download attribute style, to make this work?

exceljs/exceljs#37

@pietersv
Copy link

Old issue but this is resolved in https://github.com/protobi/msexcel-builder, a branch of this library. Example below:

function download(workbook, done) {
      var self = this;
      workbook.generate(function (err, jszip) {
        if (err) return callback(err);

        jszip.generateAsync({type: "blob", mimeType: 'application/vnd.ms-excel;'}).then(function (blob) {
          var filename = self.params.filename || "example.xlsx";
          if (navigator.msSaveBlob) { // IE 10+
            navigator.msSaveBlob(blob, filename);
          }
          else {
            var link = document.createElement("a");
            if (link.download !== undefined) { // feature detection
              // Browsers that support HTML5 download attribute
              var url = URL.createObjectURL(blob);
              link.setAttribute("href", url);
              link.setAttribute("download", filename);
              link.style.visibility = 'hidden';
              document.body.appendChild(link);
              link.click();
              document.body.removeChild(link);
            }
          }
          done(null)
        })
      })
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants