Skip to content

Instantly share code, notes, and snippets.

@mmdsharifi
Last active July 25, 2018 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmdsharifi/2e8cb8a3ff8b6ca17a7e2a8e9538d7b9 to your computer and use it in GitHub Desktop.
Save mmdsharifi/2e8cb8a3ff8b6ca17a7e2a8e9538d7b9 to your computer and use it in GitHub Desktop.
read excel file
// 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);
@mmdsharifi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment