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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Export to Excel from web service

Thread ID:

Created:

Updated:

Platform:

Replies:

127979 Dec 22,2016 03:39 PM UTC Dec 27,2016 06:34 AM UTC JavaScript 3
loading
Tags: ejGrid
Juan
Asked On December 22, 2016 03:39 PM UTC

Hi.
I want to export data from a grid to Excel using a web service.
I have the following code in aspx:


            $(function () {
                                $("#Grid1").ejGrid({
                                    Locale: "es-ES",
                                    allowPaging: true,
                                    allowSorting: true,
                                    allowGrouping: true,
                                    groupSettings: { groupedColumns: ["empresa"] },
                                    toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.ExcelExport] },
                                    columns: [
                                    { field: "empresa", headerText: "Empresa", width: 275, textAlign: ej.TextAlign.Left }
                                    ],
                                    toolbarClick: function (e) {
                                        this.exportGrid = this["export"];
                                        if (e.itemName == "exportación Excel") {
                                            this.exportGrid('WebService.asmx/ExcelExport');
                                            e.cancel = true;
                                        }
                                    }


                                });
                            })



And in the file WebService.asmx I have this code:

    <System.Web.Http.ActionName("ExcelExport")>
    <AcceptVerbs("POST")>
    Public Sub ExcelExport(gridMode As String)
        Dim gridModel1 As String = HttpContext.Current.Request.Params("GridModel")
        Dim gridProperty As GridProperties = ConvertGridObject(gridModel)
        Dim exp As New ExcelExport()
        Dim result As IEnumerable(Of Order) = db.Orders.ToList()
        exp.Export(gridProperty, result, "Export.xlsx", ExcelVersion.Excel2010, False, False, "flat-saffron")
    End Sub



But it does not work.
How do I have to make it work for export?

The Grid is in a modal div, but I've tried a div with no modal and it does not work for me either.

Thanks.














Ragavee U S [Syncfusion]
Replied On December 23, 2016 12:02 PM UTC

Hi Juan, 

We have created a grid exporting sample with webservices, which can be downloaded from the below location.

Sample Linkhttp://www.syncfusion.com/downloads/support/directtrac/general/ze/JS_Export1434829110 

We would like you to ensure the below cases in your sample. 

1.       Please ensure the URL path mentioned within the export method of the ejGrid.  
2.       Also, in toolbarClick event of the Grid, you have checked the itemName as “exportación Excel”. Have you modified the the Toolbar item Name using the ej.Grid.Locale object? 
3.       Also, the locale property is incorrectly specified in your sample code as “Locale” instead of “locale”. 

Please try the above provided sample and if you still face any difficulties, please share following information. 

1.       Screenshot/Video demo of the issue that you are facing. 
2.       If script error/exception obtained while exporting, share the screenshot of the call stack of the exception. 
3.       If possible, please reproduce the issue in the above provided sample and share. 

Regards, 
Ragavee U S. 


Juan
Replied On December 23, 2016 03:17 PM UTC

Thank you. I will check it...

Regards.

Ragavee U S [Syncfusion]
Replied On December 27, 2016 06:34 AM UTC

Hi Juan, 

Please check the given sample and let us know whether it works for you. 

Regards, 
Ragavee U S. 


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.

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

;