122
Views
18
Comments
Solved
[OutSystems Data Grid] Remove Style in Export Excel
outsystems-data-grid
Reactive icon
Forge asset by OutSystems
Application Type
Reactive

Hello,

I am using this JavaScript to export the excel (only visible column ) in Data Grid.

GridAPI.GridManager.GetGridById($parameters.Grid_Id_selected).features.export.exportToExcel($parameters.IncludeStyles, $parameters.FileName);


but Excel is looking like this

I tried to pass IncludeStyle parameter value as false but it didn't work.

Is there any other approach to remove the style.

I want Excel like below one.


Thanks.

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


Hello @Shrinjala Singh,

Just notice my last message failed.

To do this I tested and worked correctly doing the following:

  1. In the On Initialize event at the Grid block level, override the export method with:

  2. Then you just need to run it as it currently is running and you don't even need a custom call, you can use the block, you choose (the block is supported the js custom call isn't so is your call)

Hope it helps.

Cheers,
GM

2020-08-05 09-00-16
Gabriel Lundgren

Hello @Shrinjala Singh,


Just to be clear, you want to remove the padding of the cells or is it the row header?


2020-12-07 13-51-26
Shrinjala Singh

Hi Gabriel,

I want to remove padding from cell.

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

Hi @Shrinjala Singh,

Could you please share an example of your spreadsheet?
I tried to replicate that but it seems to be working as expected.

Cheers,
GM 

2020-12-07 13-51-26
Shrinjala Singh
POC_DataGrid.oml
2022-11-12 11-28-30
Gonçalo Martins
Staff

I took a look and there are no customizations in the code related to any styling nor weird chars in the data set being used, so I guess is just something on the xlsx side that might have a default cell height. Even though this has no impact on the functionality since the function generates the spreadsheet without styling and that is the end result. It seems to look at the row height in the Grid.

One thing you can try to do is to write your own export to Excel and before calling the save() method override the height value for all rows on this object:

Let me know if it works!

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


Hi @Shrinjala Singh,

Any update on this? I was able to make it work, can you provide feedback so that this can be marked as solved and hopefully be helpful to other community members.

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


Hello @Shrinjala Singh,

Just notice my last message failed.

To do this I tested and worked correctly doing the following:

  1. In the On Initialize event at the Grid block level, override the export method with:

  2. Then you just need to run it as it currently is running and you don't even need a custom call, you can use the block, you choose (the block is supported the js custom call isn't so is your call)

Hope it helps.

Cheers,
GM

2020-12-07 13-51-26
Shrinjala Singh
Hi Gonçalo Martins, Thanks for your quick response, I will try and let you know. Thanks
2020-12-07 13-51-26
Shrinjala Singh

Hi @Gonçalo Martins

Thanks for your solution, It is working fine.

I have one more issue

In data grid I have Number and Checkbox column and that column is also getting exported in Excel. So is there any way we can remove those two columns from Excel.

image


image


Thanks

Shrinjala



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

Hi @Shrinjala Singh 

You can use a similar approach as here and the documentation can be from here in Wijmo.

Cheers,
GM

2023-08-28 07-00-10
Paulo Torres
Champion

Hi @Gonçalo Martins the first column doesn't have name. How we can remove from the export as this is something that library make automatic?

Thanks, Paulo Torres

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

Hello @Paulo Torres 

That column is the row header so is not supposed to have a column title.
If you're using the latest versions of Data Grid and you want to remove that column you can override the exportToExcel API function in the Data Grid block initialize event and add the following to the parameters that by default are set to true:

includeRowHeaders: false,

Cheers,
GM

2023-08-28 07-00-10
Paulo Torres
Champion
2023-08-28 07-00-10
Paulo Torres
Champion

Hello @Gonçalo Martins,

There is an option to add columns? For example if I'm presenting 5 column in the Grid but I want to export 10 columns. It is possible?

Thanks

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

Hello @Paulo Torres 

I'm not aware of that. I know you can select the ones you want from the available bindings (I already shared that on another forum post) but the ones that are not present I don't know.
Have you looked at Wijmo's Flexgrid documentation in order to see that? If not, I would suggest you to do that.

Cheers,
GM

2023-08-28 07-00-10
Paulo Torres
Champion

Thanks @Gonçalo Martins.

I managed this with event OnFiltersChange to create the filters and after I sent the filters for a different query. Just to let you know :)

Thanks

UserImage.jpg
Gabriel Moreira

I tried to reproduce here, but I don't know what could have gone wrong, can anyone help me?

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