Hide column in Export to Excel.

Hello.

I would like to hide a column when exporting to Excel, but not hide it on the screen.

It's possible?

Regards.




3 Replies

VA Venkatesh Ayothi Raman Syncfusion Team July 26, 2018 10:54 AM UTC

Hi Juan, 

Thanks for using Syncfusion products. 

We have achieved your requirement using column’s property of visible. Please refer to the following code example and Help documentation for more information, 
toolbarClick(args:any) { 
 
            switch (args.item.text) { 
                case 'Excel Export': 
                  let colLength: number =this.Grid.getColumns().length; //get the columns length 
                  let cols: any = this.Grid.getColumns(); //get the columns 
                  for(let i: number=0; i <colLength; i++ ){  
                  if(cols[i].field == "OrderID"){ 
                    cols[i].visible = false; //hidden the corresponding column before export 
                    this.Grid.excelExport().then(((e) => cols[i].visible = true)); //enable the corresponding column after export  
                    break; 
                    } 
                    } 
            } 
        } 




Please let us know if you have any further assistance on this. 

Regards,
Venkatesh Ayothiraman. 



JU Juan July 26, 2018 11:05 AM UTC

Perfect!
It works very well!
Thank you very much!



VA Venkatesh Ayothi Raman Syncfusion Team July 27, 2018 03:48 AM UTC

Hi Juan, 
 
Thanks for the feedback. 
 
We are very happy to hear that your requirement is achieved. 
 
 
Regards, 
Venkatesh Ayothiraman. 


Loader.
Up arrow icon