23
Views
2
Comments
Solved
How to use ExcelJS with resource and database data in JavaScript (Client Action)?

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!


2025-12-09 14-11-18
Janakiraman JR
Solution

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:

  1. Create a List variable from your Entity (or Aggregate).

  2. Bind that to your screen.

  3. In your Client Action, pass that data as an input to your RunJavaScript action.


UserImage.jpg
Juvairiya Behzad

Thanks a lot! I’ll try doing it your way. 

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