Remove Columns when exporting to pdf, excel and word

Hi,
 
I want to remove some columns that are visible in the Grid, so that they do not appear in the exported pdf, excel and word. Is this possible?

Thanks


3 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team August 9, 2018 11:25 AM UTC

Hi Corazon, 

Thanks for contacting Syncfusion support. 

Query : I want to remove some columns that are visible in the Grid, so that they do not appear in the exported pdf, excel and word. Is this possible? 
 
We have achieved your requirement by removing the columns from the grid using the Columns property of Grid Properties. In ExportToExcel method we have removed the particular column using RemoveAt method. Please refer the below code example. 


public ActionResult ExportToExcel(string GridModel) 
        { 
            ExcelExport exp = new ExcelExport(); 
            var DataSource = _context.Orders.Take(100).ToList();  
            
            GridProperties gridProp = ConvertGridObject(GridModel); 
 
            gridProp.Columns.RemoveAt(3); 
 
            GridExcelExport excelExp = new GridExcelExport(); 
            excelExp.FileName = "Export.xlsx"; excelExp.Excelversion = ExcelVersion.Excel2010; 
            excelExp.Theme = "flat-saffron"; 
            return exp.Export(gridProp, DataSource, excelExp); 
        } 

We have prepared a sample for your reference. Please refer the below link for the sample. 


If you need any further assistance please get back to us. 

Regards, 
Prasanna Kumar N.S.V 
 



CC Corazon Cruz Sanchez August 10, 2018 09:21 PM UTC

Thanks my problem was solved.



PK Prasanna Kumar Viswanathan Syncfusion Team August 13, 2018 04:58 AM UTC

Hi Corazon, 

We are happy to hear that your issue has been solved.  

Please get back to us if you need any further assistance. 

Regards, 
Prasanna Kumar N.S.V 


Loader.
Up arrow icon