Adding new columns in ag grid export excel - ag-grid

How to add new columns in ag-grid in the exported excel in reactjs. I think ag-grid dynamically export excel on right click. Where does this code exactly reside and how to edit it so that I can add an extra column only in exported excel.

You should be able to back-track from the ag-grid instance, the ag-grid instance is created as shown below,
new agGrid.Grid(divElement, gridOptions);
// divElement : document element for the grid
// gridOptions: param object having all grid related information
The gridOptions , will have column definitions in it, you can try disabling visibility of a column by setting column's display property i.e., hide to false, so that on export you have the column field. For more read refer here

Related

Exporting hidden columns in materialui datagrid

is there anyway to hide a column in a materialui datagrid but also include it in exports? (Print, excel etc)

agGrid: how to disable hiding ungroupable columns after dragging them to the row group panel?

I have an angular application that I am adding an agGrid table to. I configured the table to allow grouping rows as follows:
<ag-grid-angular
[columnDefs]="columnDefs"
[rowData]="activeMethods"
[groupDefaultExpanded]="-1"
[rowGroupPanelShow]="'always'"
>
</ag-grid-angular>
And I set some of the columns to be groupable as follows:
enableRowGroup: true,
enablePivot: true,
This shows the row group panel and allows grouping of the columns I drag into it, but the issue is that "non-groupable" columns that I drag into the panel are hidden. I need those columns not to be hidden when dragged there. I know that the suppressDragLeaveHidesColumns parameter disables hiding any column when it's dragged away from the table, but I would want the "groupable" columns to still be hidden when dragged to the group panel. Is what I want to achieve easily doable?
You could keep suppressDragLeaveHidesColumns to prevent the non grouping columns to be hidden when dragged outside the grid, and then leverage the Grid Event columnRowGroupChanged to change the column that is being grouped, to be hidden. You can find the documentation for this here.
In Version 24, this can be easily achieved using the Column API method applyColumnState, documentation on this can be found here
Putting this all together:
onColumnRowGroupChanged(params) {
let columnStateParams = [];
params.columns.forEach(col => {
columnStateParams.push({ colId: col.getColId(), hide: true });
});
params.columnApi.applyColumnState({
state: columnStateParams,
});
}
I've created a Plunker showing this
The Year and Country column can be grouped only, the Athlete and Age columns cannot be grouped.

Ag-grid Collapsible Columns in Pivot Mode

In ag-grid I'm trying to use column grouping in pivot mode.
E.g. In the plunker in the below link, a 'sum(Total)' column is displayed after setting gridOptions.pivotColumnGroupTotals = 'before'. Instead of this I would want the 'Gold' column to be displayed by default, and when the column group is expanded 'Silver' and 'Bronze' columns should be displayed along with 'Gold' column.
https://www.ag-grid.com/javascript-grid-pivoting/#pivotColumnGroupTotals
ag-grid has an option to achieve this in non-pivot grids using the column property 'columnGroupShow' as in below link. But not sure how to achieve the same in pivot grids.
https://www.ag-grid.com/javascript-grid-grouping-headers/
Appreciate any help!

How to create excel report dynamically with multiple sheets using ireport

I want to create excel report dynamically which has multiple sheet is it possible to create using iReport 4.5.0?
Yes.
It is possible to create multiple sheets dynamically.
Use iReport properties field
net.sf.jasperreports.export.xls.break.after.row
Custom element property specifying if a sheet will break after the row displaying that element. It is very useful especially when displaying each report's group on a separate sheet is intended.
for full list of property fields how to use property. visit this page
Complete API of property can be found here(Reference) and here(Index)

How to create Excel document with proper cell alignment using Ireport?

I can able to create Excel document using Jasper Report but the problem is that fields are not properly aligned in the cells of excel sheet and all the data are populated in the plain surface without any cells.i.e) I cannot see any cells in the data populated area.Can u please give me suggestion to make proper Excel document with cell alignment.
I had this same struggle and came up with the following. At the time, I was using iReport (3.0.0) and was able to generate a good xls file. It may be easier in newer versions of iReport and/or JasperReports. Here's what I did:
I created a new report using the new report wizard and chose a tabular template. This creates a report with all of the fields in a line with no gaps between them. It is very key that fields are vertically aligned, that all the same height, and that there are no gaps between fields.
I removed all of the extra objects created (title, extra lines) except for the fields and the headers. I then collapsed all of the bands except the column header and detail bands.
On the report properties, I checked "Ignore pagination"
I changed the text color of the header fields, otherwise it ends up as white on white.
The rest of the important options can be found by selecting Options -> Export Options from the menu and then scrolling down to the "XLS Exporter" section. I attached a screen shot of the options I chose. You can experiment with the settings, but I found (through trial and error) that the options I ended up with work pretty well. These options are not stored in the report def file, they are attributes of the thing generating the report. iReport takes care of it when testing in that environment. We are using custom Java to generate the report in production and we set the attributes there.
XLS Exporter Dialog http://www.imagechicken.com/uploads/1270760205041768200.png