We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Export To Excel using API

Hi Team,

 Very Urgent Request.

 I am using EJ1 Controls for my project with angular 4 with typescript and ASp.net core Web api .

In That , I have scenerio for export to excel of grid visible and hide columns using API .

Please give some samples on this.

Divakaran N

5 Replies

DI divakar November 19, 2018 05:49 AM UTC

Hi team ,

Any update on my request .
Please give solution asap.

Divakaran N

MP Manivannan Padmanaban Syncfusion Team November 21, 2018 03:06 AM UTC

Hi Divakaran, 

Thanks for contacting syncfusion support. We are happy to assist you. 

We have achieve your requirement. Please refer the below code example and sample link. 

<ej-grid id="Grid" #Grid  [allowPaging]="true"  [dataSource]="data" [toolbarSettings]="toolbarSettings" (toolbarClick)="toolbar($event)" > 

export class PlanningComponent { 
    @ViewChild('Grid') Grid: EJComponents<any, any>; 
     toolbar(e: any) { 
        if (e.itemName == "Excel Export") { 
            e.cancel = true; 
        else if (e.itemName == "Word Export") { 
            e.cancel = true;//prevent the default action 
        else if (e.itemName == "PDF Export") { 
            e.cancel = true; 

// Controller Page 

        public IActionResult ExcelExport(string GridModel) 
            ExcelExport exp = new ExcelExport(); 
            var DataSource = order; 
            GridProperties gridProperty = ConvertGridObject(GridModel); 
            GridExcelExport excelExp = new GridExcelExport(); 
            excelExp.FileName = "Export.xlsx"; excelExp.Excelversion = ExcelVersion.Excel2010; 
            excelExp.Theme = "flat-saffron"; 
            return exp.Export(gridProperty, DataSource, excelExp); 
        //Word Export Method. 
        public IActionResult WordExport(string GridModel) 
            var DataSource = order; 
            WordExport exp = new WordExport(); 
            GridProperties gridProperty = ConvertGridObject(GridModel); 
            GridWordExport wordExp = new GridWordExport(); 
            wordExp.FileName = "Export.docx"; 
            wordExp.Theme = "flat-saffron"; 
            return exp.Export(gridProperty, DataSource, wordExp); 
        //PDF Export Method. 
        public IActionResult PdfExport(string GridModel) 
            var DataSource = order; 
            PdfExport exp = new PdfExport(); 
            GridProperties gridProperty = ConvertGridObject(GridModel); 
            GridPdfExport pdfexp = new GridPdfExport(); 
            pdfexp.FileName = "Export.pdf"; 
            pdfexp.Theme = "flat-saffron"; 
            return exp.Export(gridProperty, DataSource, pdfexp); 
        public GridProperties ConvertGridObject(string gridProperty) 
            GridProperties gridProp = new GridProperties(); 
            gridProp = (GridProperties)JsonConvert.DeserializeObject(gridProperty, typeof(GridProperties)); 
            return gridProp; 

Manivannan Padmanaban. 

GM Gangabharathy Murugasen Syncfusion Team November 21, 2018 04:41 AM UTC

From: Nagappan, Divakaran  
Hi Syncfusion, 

For a past two days i was waiting for your reply but not yet got any reply from your side. 

Please check and give some Suggesion otherwise i dont have any option other than escalation. 
Thanks & Regards, 
Divakaran N 

MP Muthukumar Periasamy November 22, 2018 09:12 AM UTC

Hi Manivannan,

     Thanks for your support.

      I was trying with your solution but i don't know how to add syncfusion dll in WebApi.

    Your are sharing the examples with MVC project but i am having WebAPI . 

   Please Help me on this.

Divakaran N

VN Vignesh Natarajan Syncfusion Team November 23, 2018 12:15 PM UTC

Hi Divakaran, 

Thanks for the update. 

Query1:   I was trying with your solution but i don't know how to add Syncfusion dll in WebApi. 

You can find the Syncfusion assemblies (dll reference) in the below location of your installed folder 

Location: Installed location\Syncfusion\Essential Studio\\Assemblies\Frame work version. 
We can also get the dll from the nuget packages. Please do refer the below help documentation link, 

Query2:     You are sharing the examples with MVC project but i am having WebAPI .  
The sample which we provided in the last update is Angular-webAPI in Asp.netCore  project only. If you are facing any difficulties while implementing the solution. 

Please get back to us with following details. 

  1. Share the Error screenshot.
  2. Share the issue are you facing in detail.

Vignesh Natarajan 

Live Chat Icon For mobile
Up arrow icon