exceljs / exceljs/exceljs

Can't load file from input file after updating from 3.5 to 3.7

Open
#1,098 5 comments 1 reaction 0 assignees View on GitHub
bug enhancement
Dominant language
JavaScript
Stars
15.5k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

Hi,

I updated exceljs from 3.5 to 3.7 and I can't load a file from an input type file (with reactjs)
Here is a sample of code wich works in 3.5 but not in 3.7

``` javascript
import React from 'react'
import {useState} from 'react'
import ExcelJS from 'exceljs'

function App() {

const [file, setFile] = useState({})

function handleFormSubmit(e){

loadFile().then(workbook => {
console.log(workbook)
})

e.preventDefault()
e.stopPropagation()
}

function loadFile(){
return new Promise(function(resolve, reject){
file.arrayBuffer().then(b => {
let workbook = new ExcelJS.Workbook()
workbook.xlsx.load(b).then(() => {
resolve(workbook)
})
})
.catch(e => reject(e))
})
}

return (


handleFormSubmit(e)}>
File : setFile(e.target.files[0])} />





);
}

export default App
```

I get this error :

Unhandled Rejection (Error): Chunk must be one of type String, Buffer or StringBuf.
On workbook.xlsx.load(b).then(() => {

Thx for helping

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.