339
Views
3
Comments
Solved
[OutSystems Data Grid] How to chnage what gets exported on excel file
outsystems-data-grid
Reactive icon
Forge asset by OutSystems
Application Type
Reactive

Hi there,


Right now I am trying to change on how the excel export works for the datagrid. Since I have several fields with links and booleans I don't want to show I would like to filter out those columns on the export (or be able to make a different export action that excludes these columns).

From what I see from Wijmo, there should be something like that here https://www.grapecity.com/wijmo/api/interfaces/wijmo_grid_xlsx.iflexgridxlsxoptions.html#includecolumns

I tried multiple times to set a function for this, like this

wijmo.grid.xlsx.FlexGridXlsxConverter.save($parameters.GridObject, {      
 includeColumns: function(column) {  return (column.binding !== 'DatagridRow.test');}},'test.xlsx');


Every time I try to do this I get this error: "Cannot read properties of undefined (reading 'appendChild')".
From what I see, this happens because the main object for the grid is missing the appendChild.

Did anyone had this issue and managed to get a solution for this?
Thanks in advance for any help provided.

2021-12-03 13-55-36
Jorge Silva
Solution

Hi there Gonçalo,


Thanks for pointing out in the right direction. I have to say, I would expect this to be available as is on the datagrid, I can imagine this is not such a weird use case.

But anyways, I will leave here a detailed answer for this issue:

  • Since this is not a supported feature at this point, just like Gonçalo stated, one way to do this is to actually overwrite the actual function that does the export.
  • The actual function is located at GridAPI.GridManager.GetActiveGrid().features.export.exportToExcel (this can also be achieved using the GetGridById, to make sure it always with more than 1 grid at the time).
  • For this function (from the Wijmo website, here) there is an option includeColumns. With this one we can specify which columns do we want on the export.
  • A way to overwrite this this function could be this way: 

  • After defining this JS, make sure to change it before the export happens! This could be right after render, or before the action for export is called
  • After that, the export should behave as expected.

In case there are other options from Wijmo that could eventually correlate to these options, probably this is a good way to do it.



2025-03-05 10-16-14
Suriyakala S

hi Jorge Vicente Canhoto da Silva, 

This is working for exporting datagrid into excel. Can we use the same js code for the exporting datagrid To CSV also? 

if yes, can you provide the modified js code for exporting the datagrid to CSV also?


2022-11-12 11-28-30
Gonçalo Martins
Staff

Hello Jorge,

Could you share the OML with the use case and issue you're mentioning?
Since this is a very customizable use case, maybe you can that a look at the approach I mentioned here (not the same use case but is to manipulate the data on the Excel export so you could explore the object configs)

Cheers,
GM

2021-12-03 13-55-36
Jorge Silva
Solution

Hi there Gonçalo,


Thanks for pointing out in the right direction. I have to say, I would expect this to be available as is on the datagrid, I can imagine this is not such a weird use case.

But anyways, I will leave here a detailed answer for this issue:

  • Since this is not a supported feature at this point, just like Gonçalo stated, one way to do this is to actually overwrite the actual function that does the export.
  • The actual function is located at GridAPI.GridManager.GetActiveGrid().features.export.exportToExcel (this can also be achieved using the GetGridById, to make sure it always with more than 1 grid at the time).
  • For this function (from the Wijmo website, here) there is an option includeColumns. With this one we can specify which columns do we want on the export.
  • A way to overwrite this this function could be this way: 

  • After defining this JS, make sure to change it before the export happens! This could be right after render, or before the action for export is called
  • After that, the export should behave as expected.

In case there are other options from Wijmo that could eventually correlate to these options, probably this is a good way to do it.



2025-03-05 10-16-14
Suriyakala S

hi Jorge Vicente Canhoto da Silva, 

This is working for exporting datagrid into excel. Can we use the same js code for the exporting datagrid To CSV also? 

if yes, can you provide the modified js code for exporting the datagrid to CSV also?


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