3

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
},
alexander.polomodov
  • 5,396
  • 14
  • 39
  • 46
Satendra Jindal
  • 1,048
  • 3
  • 10
  • 15

2 Answers2

1

below code will solve your problem

var columnsForExport=[];
var allColumns=gridOption.columnApi.getAllColumns();

allColumns.forEach((element:any) => {
    if(element.colId!="#"){
        columnsForExport.push(element.colId)
    }
});
  • { checkboxSelection: true, suppressMenu: true, suppressSorting: true, suppressFilter: true, width: 30, pinned: true, suppressExcelExport :true, columnKeys:columnsForExport }, – Nishant Kumar Dec 05 '17 at 15:56
1

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.

Rafe
  • 395
  • 1
  • 4
  • 15