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
Invalid HTML: could not find <table> #1110
Comments
That error is triggered when the file is suspected to be HTML but the actual TABLE tag cannot be found. Can you capture and share an example file? |
Hey, |
If it's an actual XLSM file, it would start with |
The same thing happens to me and in the registry of the console everything looks very good, but throws the same error |
I found the error! in rectJS the file xlsx must be in the 'public' folder |
I had the same issue when I use node to read the excel file in the docker container, it shows Error: Invalid HTML: could not find .I debugged into the xlsx.js file and found that the function firstbyte(d, o))[0] return 0x3C which indicated as xlml file, it suppose to return 0x50, the module source code piece below: switch((n = firstbyte(d, o))[0]) { |
What do you mean about the 'public' folder, should we name the folder as public or have this folder 's permission go public? |
@wodeleeway @MedinaGitHub file type is deduced by looking at the magic (first few bytes), that's what you're seeing in that code block. If the file starts with "<" the immediate guess is that it's an HTML or XML-based format. If you are using XHR or fetch and requesting a file that isn't available, you'll get back the 404 response. Usually the body is a small HTML page, which is why you see the error in question. Your code should defend against it by checking the status of the request. With fetch(myRequest).then(function(res) {
if(res.status == 404) { /* file not found */ } How to resolve the 404 errors is beyond the scope of this project. |
This worked for me too |
Working on a React App and putting my xlsx file in the |
EDIT: If you are seeing this error when trying to read a data from an external resource (e.g. XHR,
fetch
,axios
), check the response code of the request. The data might be a 404 page. If it is a 404, make sure the file exists and is available.When building a project with CRA or other templates, spreadsheets must be placed in the
public
folder.Your code should defend against network issues by checking the status of the request. With
fetch
the status code is available asres.status
in the first callback:Usually it does succedd but sometimes I get this error and it crashes any idea?
if(!mtch) throw new Error("Invalid HTML: could not find
");^
Error: Invalid HTML: could not find
at html_to_sheet (/.../node_modules/xlsx/xlsx.js:17000:19)
at Object.html_to_book [as to_workbook] (/.../node_modules/xlsx/xlsx.js:17056:28)
at parse_xlml_xml (/.../node_modules/xlsx/xlsx.js:13714:26)
at parse_xlml (/.../node_modules/xlsx/xlsx.js:14362:53)
at readSync (/../node_modules/xlsx/xlsx.js:18394:21)
at Object.readFileSync (/.../node_modules/xlsx/xlsx.js:18412:9)
at Request._callback (/.../server/routes/api.js:137:24)
at Request.self.callback (/.../node_modules/request/request.js:186:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request. (/.../node_modules/request/request.js:1163:10)
at emitOne (events.js:101:20)
at Request.emit (events.js:188:7)
at IncomingMessage. (/.../node_modules/request/request.js:1085:12)
at IncomingMessage.g (events.js:291:16)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
[nodemon] app crashed - waiting for file changes before starting...
The text was updated successfully, but these errors were encountered: