Posted 2 September 2025, 7:41 pm EST
How do I load an Excel (.xlsx) file given a bytes array of the excel file?
Forums Home / Spread / SpreadJS
Posted by: peter on 2 September 2025, 7:41 pm EST
Posted 2 September 2025, 7:41 pm EST
How do I load an Excel (.xlsx) file given a bytes array of the excel file?
Posted 2 September 2025, 11:54 pm EST
Hi Peter,
It is possible to load an Excel file from a byte array by first creating a blob and then using the spread.import method. Please refer to the code snippet below that illustrates this approach:
const uint8 = new Uint8Array(excelBytes);
const blob = new Blob([uint8], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
});
spread.import(blob, function () {}, function (err) {}, { fileType: GC.Spread.Sheets.FileType.excel });
You can further refer to the attached code sample that uses the above code snippet and loads the Excel file from a byte array (see below).
Please let us know if you require any further assistance.
Kind Regards,
Chirag Gupta
Posted 3 September 2025, 12:32 am EST
Thanks. I’m using React. Can you show an example of loading the bytes with that?
Posted 3 September 2025, 1:24 am EST
Hi,
Certainly! In React, you can load an Excel file from a byte array as discussed in the previous response. Please refer to the attached React code sample that demonstrates the complete working of Excel import in SpreadJS (see below).
Please don’t hesitate to contact us if you require any additional guidance.
Kind Regards,
Chirag Gupta