How to hide the select all(checkbox) column in excel or csv export.
{
checkboxSelection: true,
suppressMenu: true,
suppressSorting: true,
suppressFilter: true,
width: 30,
pinned: true,
suppressExcelExport :true,
headerCellRenderer: this.selectAllRenderer
},
below code will solve your problem
var columnsForExport=[];
var allColumns=gridOption.columnApi.getAllColumns();
allColumns.forEach((element:any) => {
if(element.colId!="#"){
columnsForExport.push(element.colId)
}
});
As for now, the suppressExcelExport: true property works only for the entire grid, not the columns!
However there is a nice workaround which will enable any custom column property (e.g. suppressExcelExport) to act like a real working property as you asked.
All you need is calling this function on a button click or add context menu item:
function exportActiveColumns() {
let allColumns = gridOptions.columnApi.getAllColumns();
let exportColumns = allColumns .filter(col => !col.userProvidedColDef.suppressExcelExport);
gridOptions.api.exportDataAsExcel({
columnKeys: exportColumns,
});
}
Make sure suppressExcelExport is false for the grid, otherwise there will be no result after calling exportDataAsExcel api.
Exact same thing works for CSV.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With