Created
October 22, 2021 07:31
-
-
Save connor-davis/2d20905e41ba417f252f214c6bc795a1 to your computer and use it in GitHub Desktop.
xlsx import
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let element = document.createElement('input'); | |
element.type = 'file'; | |
element.accept = '.xls,.xlsx'; | |
element.click(); | |
element.addEventListener('change', ({ target: { files } }) => { | |
let file = files[0]; | |
let filename = file.name; | |
let reader = new FileReader(); | |
reader.onloadend = () => { | |
let data = reader.result; | |
let workbook = XLSX.read(data, { type: 'binary' }); | |
setImportState({ ...importState, workbook }); | |
setImportResourcesModalActive(true); | |
}; | |
reader.readAsBinaryString(file); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment