question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Corrupted zip : can't find end of central directory

See original GitHub issue

EDIT: if you encounter this issue, confirm you are using the latest version and that you are using the correct input type! See https://github.com/sheetjs/sheetjs#input-type

For example, using a FileReader with readAsArrayBuffer will call the load event where the result is an ArrayBuffer, so type should be "array"

If data is received through an XHR or fetch, verify that the source data is not UTF8-encoded. Some platforms like AWS Gateway API do this automatically and require an override as explained in the function demo

I am trying to use this library to parse a base64 encoded .xslx file on the server using node.js. I have also removing the base64 header info and loading the data into a binary buffer, but I get the same error.

Here is my function to parse the file:

var parseFile = function(data){
  var xlsx = XLSX.read(data, {type: 'base64'});
  var sheet_name_list = xlsx.SheetNames;
  xlsx.SheetNames.forEach(function(y) {
    for (z in xlsx.Sheets[y]) {
      if(z[0] === '!') continue;
      console.log(y + "!" + z + "=" + JSON.stringify(xlsx.Sheets[y][z].v));
    }
  });
};

However, when I try to parse the data, I get the following error.

Error: Corrupted zip : can't find end of central directory
        at Object.ZipEntries.readEndOfCentral (/Users/.../node_modules/xlsx/jszip.js:2087:27)
        at Object.ZipEntries.load (/Users/.../node_modules/xlsx/jszip.js:2104:18)
        at Object.ZipEntries (/Users/.../node_modules/xlsx/jszip.js:2010:18)
        at Object.JSZip.load (/Users/.../node_modules/xlsx/jszip.js:2115:22)
        at Object.JSZip (/Users/.../node_modules/xlsx/jszip.js:5:14)
        at Object.readSync [as read] (/Users/.../node_modules/xlsx/xlsx.js:940:24)
        at parseFile (/Users/.../routes/tickets.js:35:19)

any thoughts as to why this might be happening? When I load my file into your demo site, it parses it to json just fine.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:3
  • Comments:38 (12 by maintainers)

github_iconTop GitHub Comments

4reactions
hlynurlcommented, Jun 24, 2019

@SheetJSDev thank you for your advice.

I have confirmed I am dealing with a buffer. This is not something that happened while writing new code. This is all of a sudden happening in my codebase which worked fine before on the exact same files. I even have an app in production working fine which was deployed from my last commit but if I clear all changes and revert back to that commit this still happens.

  • I suspect this has something to do with .DS_Store files on my mac so I have tried to delete them but this is still happening.
  • I have tried to remove all node modules and re-install few times.
  • … do you have any other ideas?
3reactions
PedramMarandicommented, May 28, 2019

After 6 years there is no solution to this problem 👯 I’m facing with the same issue, I’m trying to read Buffer but I get the below exception

Error: Corrupted zip : can't find end of central directory",
            "    at ZipEntries.readEndOfCentral (/Users/pedromarandi/projects/replenishment/node_modules/xlsx/jszip.js:2281:19)",
            "    at ZipEntries.load (/Users/pedromarandi/projects/replenishment/node_modules/xlsx/jszip.js:2343:14)",
            "    at new ZipEntries (/Users/pedromarandi/projects/replenishment/node_modules/xlsx/jszip.js:2167:14)",
            "    at JSZipSync.module.exports [as load] (/Users/pedromarandi/projects/replenishment/node_modules/xlsx/jszip.js:580:18)",
            "    at new JSZipSync (/Users/pedromarandi/projects/replenishment/node_modules/xlsx/jszip.js:527:14)",
            "    at read_zip (/Users/pedromarandi/projects/replenishment/node_modules/xlsx/xlsx.js:20267:24)",
            "    at Object.readSync [as read] (/Users/pedromarandi/projects/replenishment/node_modules/xlsx/xlsx.js:20335:69)",
            "    at read (/Users/pedromarandi/projects/replenishment/src/lib/sheetUtils.js:23:15)",
            "    at _callee$ (/Users/pedromarandi/projects/replenishment/src/lib/validations/validatePurchaseOrderFile.js:28:21)",
            "    at tryCatch (/Users/pedromarandi/projects/replenishment/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:45:40)",
            "    at Generator.invoke [as _invoke] (/Users/pedromarandi/projects/replenishment/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:271:22)",
            "    at Generator.prototype.(anonymous function) [as next] (/Users/pedromarandi/projects/replenishment/node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:97:21)",
            "    at asyncGeneratorStep (/Users/pedromarandi/projects/replenishment/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)",
            "    at _next (/Users/pedromarandi/projects/replenishment/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)",
            "    at process._tickCallback (internal/process/next_tick.js:68:7)"```
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Corrupted zip : can't find end of central directory - XLSX
In my case I was working on .xls file. Opened the file and stored it as Excel Workbook (.xlsx). This solved my problem....
Read more >
Can't find end of central directory : is this a zip file - GitLab
But, it keeps throwing this error "Can't find end of central directory : is this a zip file". Bye the way it reads...
Read more >
Corrupted zip : can't find end of central directory jszip" | SAP ...
During " Download UI5 library " stage of HAT (Hybrid Application Toolkit) development the below error appears: Error: Corrupted zip : can't find...
Read more >
Azure Data Factory "Error while publishing: Corrupted zip
Azure Data Factory "Error while publishing: Corrupted zip: can't find end of central directory". After pushing a commit into my collaboration ...
Read more >
Fix Zip File Error End-Of-Central-Directory Signature Not Found
How to Resolve ZIP File Error Cannot Find Central Directory Signature? ; When the data in a ZIP archive is damaged, leads to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found