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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Export To Excel using API

Thread ID:

Created:

Updated:

Platform:

Replies:

140996 Nov 18,2018 07:11 AM UTC Nov 23,2018 12:15 PM UTC Angular 5
loading
Tags: ejGrid
divakar
Asked On November 18, 2018 07:11 AM UTC

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.

Thanks,
Divakaran N

divakar
Replied On November 19, 2018 05:49 AM UTC

Hi team ,

Any update on my request .
Please give solution asap.



Thanks,
Divakaran N

Manivannan Padmanaban [Syncfusion]
Replied On 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)" > 
        <e-columns> 
          …………………………… 
        </e-columns> 
    </ej-grid> 

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


// Controller Page 

   [Route("api/planning/ExcelExport")] 
        [ActionName("ExcelExport")] 
        [HttpPost] 
        public IActionResult ExcelExport(string GridModel) 
        { 
            BindDataSource(); 
            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. 
        [Route("api/planning/WordExport")] 
        [ActionName("WordExport")] 
        [HttpPost] 
        public IActionResult WordExport(string GridModel) 
        { 
            BindDataSource(); 
            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. 
        [Route("api/planning/PdfExport")] 
        [ActionName("PdfExport")] 
        [HttpPost] 
        public IActionResult PdfExport(string GridModel) 
        { 
            BindDataSource(); 
            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; 
        } 




Regards, 
Manivannan Padmanaban. 


Gangabharathy Murugasen [Syncfusion]
Replied On 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 


Muthukumar
Replied On 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.

Thanks,
Divakaran N


Vignesh Natarajan [Syncfusion]
Replied On 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\16.2.0.41\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.

Regards, 
Vignesh Natarajan 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;