Error: Corrupted zip : can't find end of central directory - XLSX
Asked Answered
Q

4

7

I'm trying to read my excel file by using XLSX npm. While read its throwing error as 'Corrupted zip : can't find end of central directory'

This is error I'm getting,

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)
Query answered 23/1, 2020 at 6:39 Comment(0)
Q
3

Why its throwing error is, we are trying to read the file its completely downloaded from any cloud or somewhere else. So before read your excel file ensure that file is not in write mode. Once file completely downloaded try to populate the Excel data.

Hope it will solve your issue.

Query answered 23/1, 2020 at 6:39 Comment(0)
S
1

In my case I was working on .xls file. Opened the file and stored it as Excel Workbook (.xlsx). This solved my problem. The reason I had .xls file was because I was working on a migration project and the earlier file was in .xls.

Spodumene answered 26/9, 2022 at 16:35 Comment(0)
C
0
 location /uploads {

             proxy_pass http://127.0.0.1:5050;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection 'upgrade';
             proxy_set_header Host $host;
             proxy_cache_bypass $http_upgrade;
             proxy_redirect off;
  }

Since i am using nginx setup in my server, so i just proxy passed the headers so that it identifies the path where my file is stored and get it back fully. And it worked for me!

Casaba answered 10/4, 2020 at 8:18 Comment(0)
G
0

In my case I was using exceljs library and I used

await workbook.xlsx.load(path);

instead of

await workbook.xlsx.readFile(path);

load method takes file buffer as an argument but as I provided string it threw this error. Probably you also used the wrong method

Gastineau answered 27/8 at 11:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.