33
Views
8
Comments
Solved
Read excel file using Sheetjs library in O11


Hi,

 I’m working on a Reactive Web App in OutSystems. I want to let the user upload an Excel file, read its data, make some changes, and then save/download the updated file — all on the client side using JavaScript and SheetJS (xlsx.js). I tried reading the file using SheetJS, but I'm getting an error. It seems there’s an issue with the binary data format, and I couldn’t read the file properly. Has anyone done this in OutSystems? What is the correct way to read an Excel file using  JavaScript in a Client Action? 

Any example or help would be really appreciated.

2022-07-24 08-50-37
Gokula Kannan P
Solution


Use this method—it should work:

  1. Download the library from the CDN:

    https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js

  2. Import it into the Scripts section of your module.

  3. Add it to the Required Scripts property for the relevant screen or block.

This ensures the library is loaded before your JavaScript runs. 




output: 


2022-07-24 08-50-37
Gokula Kannan P

Hi @Juvairiya Jabbar,

OutSystems' binary data type can store a base64 string without any additional metadata. 

var workbook = XLSX.read($parameters.BinaryData, { type: "base64" }); 

Another approach is to convert the file into an array buffer. 


If you've already tried this approach and still encountering issues, could you provide more details on how the binary file is being handled in OutSystems?

UserImage.jpg
Juvairiya Behzad

Hi Gee Kay,

Thanks for your suggestions!

I actually already tried both approaches:But in both cases, I still got the same issue — XLSX.read is not a function. I've attached a sample of what I did in the JavaScript code, in case it helps spot something I missed. 

Please let me know if there’s anything else I can try — I’ve been stuck on this. 

2022-07-24 08-50-37
Gokula Kannan P
Solution


Use this method—it should work:

  1. Download the library from the CDN:

    https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js

  2. Import it into the Scripts section of your module.

  3. Add it to the Required Scripts property for the relevant screen or block.

This ensures the library is loaded before your JavaScript runs. 




output: 


UserImage.jpg
Juvairiya Behzad

Hi Gee Kay,

Thanks a lot for your help! I was stuck on this and tried many things, but your suggestion worked. Really appreciate it! 

UserImage.jpg
Vu Ky

Hi Gee Kay,
I followed the steps you provided and was able to read the file content by checking the console in the browser. I'd like to ask how I can assign that result to a local variable in OutSystems. When I try to assign it to a local variable with the data type Text, it returns an empty string ("").
Thank you! 

UserImage.jpg
Vu Ky

Hi, I see the result and was able to assign it to a local variable. Thank you! 

2023-12-11 08-54-13
Neha Agrawal
Champion

@Juvairiya Jabbar 

In OutSystems Reactive Web applications, Screen Actions are indeed executed entirely on the client-side. 

Could you share a bit more about how you are currently reading the file in your JavaScript code? Specifically, how are you accessing the file data from the file input and how are you passing it to SheetJS? 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.