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.

Export to Excel not working ExportExcel()

Thread ID:

Created:

Updated:

Platform:

Replies:

130055 Apr 19,2017 02:37 AM Apr 20,2017 08:23 AM ASP.NET Web Forms 1
loading
Tags: Grid
Brent Hector
Asked On April 19, 2017 02:37 AM

Tried following a couple example\s to export the grid to Excel and getting these errors



Imports Syncfusion.EJ.Export <---Import statement unnecessary


    Protected Sub gvTimeSheet_ServerExcelExporting(ByVal sender As Object, ByVal e As Syncfusion.JavaScript.Web.GridEventArgs)
        Dim exp As New ExcelExport() ' <-- getting  a Type not defined error
        Dim data As DataView = CType(SqlData.Select(New DataSourceSelectArguments()), DataView)
        Dim dt As DataTable = data.Table
        exp.Export(gvTimeSheet.Model, dt, "Export.xlsx", ExcelVersion.Excel2010, True, True, "flat-lime")


    End Sub

ASPX:

   <div id="grid" style="max-width: 910px">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>


                <ej:Grid ID="gvTimeSheet" runat='server' AllowPaging="True" AllowSorting="True" Width="900px" CssClass="" OnServerEditRow="EditEvents_ServerEditRow"
                    OnServerAddRow="EditEvents_ServerAddRow" OnServerDeleteRow="EditEvents_ServerDeleteRow" OnServerExcelExporting="gvTimeSheet_ServerExcelExporting">

                    <ClientSideEvents ActionComplete="complete" EndAdd="endAdd" EndDelete="endDelete" EndEdit="endEdit"
                        RecordDoubleClick="doubleClick"  />
                   
                    <EditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" EditMode="Dialog"  />
                    <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel,,excelExport"></ToolbarSettings>
                    <Columns>
                        <ej:Column DataType="number" Field="JobID" IsPrimaryKey="true" IsIdentity="true" AllowEditing="False" Width="50px">
                        </ej:Column>
                        <ej:Column DataType="number" Field="ClientID" ForeignKeyField="ClientID" ForeignKeyValue="CompanyName" EditType="Dropdown" Width="150px">
                            <ValidationRule>
                                <ej:KeyValue Key="number" Value="true" />
                            </ValidationRule>
                        </ej:Column>

                        <ej:Column DataType="number" Field="EmployeeID" ForeignKeyField="EmployeeID" ForeignKeyValue="EmployeeName" EditType="Dropdown" Width="150">
                            <ValidationRule>
                                <ej:KeyValue Key="required" Value="true" />
                            </ValidationRule>
                        </ej:Column>

                        <ej:Column DataType="number" Field="WorkCodeID" ForeignKeyField="WorkCodeID" ForeignKeyValue="WorkCode" EditType="Dropdown" Width="120px">
                            <ValidationRule>
                                <ej:KeyValue Key="required" Value="true" />
                            </ValidationRule>
                        </ej:Column>

                        <ej:Column DataType="date" Field="WorkDate" EditType="Datepicker" Format="{0:dd/MM/yyyy}" Tooltip="Enter DD/MM/YYYY" Width="85px">
                            <ValidationRule>
                                <ej:KeyValue Key="required" Value="true" />
                            </ValidationRule>
                        </ej:Column>

                        <ej:Column DataType="number" Field="Hours" EditType="Numeric" Width="75px">
                            <ValidationRule>
                                <ej:KeyValue Key="required" Value="true" />
                                <ej:KeyValue Key="number" Value="true" />
                            </ValidationRule>
                        </ej:Column>
                        <ej:Column DataType="number" Field="Rate" EditType="Numeric" Format="{0:C2}" Width="75px">
                            <ValidationRule>
                                <ej:KeyValue Key="required" Value="true" />
                                <ej:KeyValue Key="number" Value="true" />
                            </ValidationRule>
                        </ej:Column>
                        <ej:Column DataType="string" Field="WorkDescription" Width="150px">
                        </ej:Column>
                    </Columns>

                </ej:Grid>
                <asp:SqlDataSource ID="SqlData" runat="server" ConnectionString="<%$ ConnectionStrings:constr %>"
                    SelectCommand="SELECT * FROM [TimeSheets]"></asp:SqlDataSource>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
Code:

Mani Sankar Durai [Syncfusion]
Replied On April 20, 2017 08:23 AM

Hi Brent, 

Thanks for contacting Syncfusion support. 
We have analyzed your query and we are able to reproduce only when necessary file (Syncfusion.EJ.Export) is not referred. So please refer the necessary file to export the grid. Also check whether the dll’s referred in the same version. 
We have also prepared a sample that can be downloaded from the below link. 
In this sample based on the code example we have exported the grid SqlData with foreign key columns. 
Refer the code example. 
[GridFeatures.aspx] 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 
    <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
        <ContentTemplate> 
             <ej:Grid ID="Grid1" AllowPaging="True" DataSourceID="SqlData" AllowSorting="True" Width="900px" OnServerWordExporting="FlatGrid_ServerWordExporting" OnServerPdfExporting="FlatGrid_ServerPdfExporting" 
                OnServerExcelExporting="FlatGrid_ServerExcelExporting" 
                runat="server"> 
                <Columns> 
                    <ej:Column DataType="number" Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="Right" Width="90" /> 
                    <ej:Column DataType="number" Field="EmployeeID"  ForeignKeyField="EmployeeID" ForeignKeyValue="FirstName"  HeaderText="Employee ID" TextAlign="Right" Width="110" /> 
... 
 
                </Columns> 
... 
            </ej:Grid> 
            <asp:SqlDataSource ID="SqlData" runat="server" ConnectionString="<%$ ConnectionStrings:SQLConnectionString %>" 
                SelectCommand="SELECT * FROM [Orders]"></asp:SqlDataSource> 
        ... 
</asp:Content> 
[GridFeatures.aspx.vb] 
 
Imports System.Collections 
Imports System.Collections.Generic 
... 
Imports Syncfusion.XlsIO 
Imports Syncfusion.EJ.Export              //it is must to refer 
  Protected Sub FlatGrid_ServerExcelExporting(sender As Object, e As Syncfusion.JavaScript.Web.GridEventArgs) 
        Dim exp As New ExcelExport() 
        Dim data As DataView = CType(SqlData.Select(New DataSourceSelectArguments()), DataView) 
        Dim dt As DataTable = data.Table 
        exp.Export(Grid1.Model, dt, "Export.xlsx", ExcelVersion.Excel2010, True, True, _ 
            "flat-lime") 
    End Sub 

Refer the documentation link. 

If you still face the issue please get back to us with the following details. 
1.       Share the video/ screenshot of the issue you have faced. 
2.       If possible please reproduce the issue in the above attached sample 
The provide information will help us to analyze the issue and provide you the response as early as possible. 
Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


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.

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.

;