69
Views
17
Comments
Solved
[OutSystems Data Grid] Remove Style in Export Excel
data-grid-reactive
Reactive icon
Forge component by Gonçalo Martins
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.

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?


Hi Gabriel,

I want to remove padding from cell.

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 

POC_DataGrid.oml

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!


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.

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

Hi Gonçalo Martins, Thanks for your quick response, I will try and let you know. Thanks

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



Hi @Shrinjala Singh 

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

Cheers,
GM

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

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

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

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

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

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