Hi ,
In my screen I have a button with a Client Action that runs some JavaScript.
I want to Use the ExcelJS library to work with Excel files.Load an Excel template (uploaded as a Resource) in JavaScript.Write data from a database entity into it.Download the final Excel file.
How can I ,
Get the Excel template (resource) in JavaScript?
Pass the entity data from OutSystems to JavaScript?
Thanks in advance!
Hi Juvairiya,
In your OutSystems module:
Upload your Excel file under Data > Resources.
Set Deploy Action to Deploy to Target Directory.
Set Public = Yes.
This makes the file accessible via a URL like:
/{YourModuleName}/{YourTemplate}.xlsx
Use fetch() in JavaScript to load the file as an ArrayBuffer:
const response = await fetch('/YourModuleName/YourTemplate.xlsx');
const arrayBuffer = await response.arrayBuffer();
const workbook = await ExcelJS.Workbook.from(arrayBuffer);
Make sure ExcelJS is properly loaded in your app (either via script tag or through a CDN).
From your OutSystems screen:
Create a List variable from your Entity (or Aggregate).
Bind that to your screen.
In your Client Action, pass that data as an input to your RunJavaScript action.
Thanks a lot! I’ll try doing it your way.