Last active
July 25, 2018 06:58
-
-
Save mmdsharifi/2e8cb8a3ff8b6ca17a7e2a8e9538d7b9 to your computer and use it in GitHub Desktop.
read excel file
This file contains 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
// first: get excel file from server, with responseType: "arraybuffer" | |
const data = new Uint8Array(this.excelData); | |
const arr = new Array(); | |
for (let i = 0; i !== data.length; ++i) { | |
arr[i] = String.fromCharCode(data[i]); | |
} | |
const bstr = arr.join(""); | |
const workbook = XLSX.read(bstr, { type: "binary" }); | |
const first_sheet_name = workbook.SheetNames[0]; | |
const worksheet = workbook.Sheets[first_sheet_name]; | |
this.excelhtml = XLSX.utils.sheet_to_html(worksheet); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks to https://github.com/SheetJS/js-xlsx/tree/master/demos/angular2 👍