[CLOSED] export to excel is not working

  1. #1

    [CLOSED] export to excel is not working

    When I am clicking on Export to Excel button it is just refreshing the grid and not at all opening excel sheet as mentioned in example. Required urgent help on same.
    PF below code:


    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Xml.Xsl" %>
    <%@ Import Namespace="System.Xml" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    
        
       
         <script runat="server">
            private object permittype
            {
                get
                {
                    return new object[]
                {
                   
                    new object[] { "Both", "Weight & Period"},
                    new object[] { "Period", "Period"},
                    new object[] { "Weight", "Weight"}
                    
                    
                };
                }
            }
    
    
            private object transactionstatus
            {
                get
                {
                    return new object[]
                {
                   
                    new object[] { 1, "Draft"},
                    new object[] {2, "Submitted"},
                    new object[] { 3, "Approved"}
                    
                    
                };
                }
            }
    
    
            protected void ToExcel(object sender, EventArgs e)
            {
               
                string json = JSON.Serialize(this.Store7.Data); //LIST to JSON ...
                StoreSubmitDataEventArgs eSubmit = new StoreSubmitDataEventArgs(json, null);
                XmlNode xml = eSubmit.Xml;
                this.Response.Clear();
                this.Response.ContentType = "application/vnd.ms-excel";
                this.Response.AddHeader("Content-Disposition", "attachment; filename=submittedData.xls");
                XslCompiledTransform xtExcel = new XslCompiledTransform();
                xtExcel.Load(Server.MapPath("~/Template/Excel.xsl"));
                xtExcel.Transform(xml, null, this.Response.OutputStream);
                this.Response.End();
            }
    
            
    
        </script>
    <html>
    <head id="Head2" runat="server">
        
        
        <script>
            var saveData = function () {
                App.Hidden1.setValue(Ext.encode(App.GridPanel1.getRowsValues({ selectedOnly: false })));
            };
        </script>
    </head>
    
    
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager2" runat="server" />
           
            <ext:Hidden ID="Hidden1" runat="server" />
    
            <ext:Store ID="Store7" runat="server" AutoLoad="true">
                <AutoLoadParams>
                                <ext:Parameter Name="start" Value="0" Mode="Raw" />
                                <ext:Parameter Name="limit" Value="10" Mode="Raw" />
                            </AutoLoadParams>
                            <Proxy>
                                <ext:RestProxy Url="~/CustomerRegistrationReport/GetData">
                                    <Reader>
                                        <ext:JsonReader Root="data" MessageProperty="message" TotalProperty="total" />
                                    </Reader>
                                     
                                    
                                </ext:RestProxy>
                            </Proxy>
                            <Model>
                                <ext:Model ID="Model5" runat="server" IDProperty="Id" Name="WmsCustomerRegistrationReport">
                                    <Fields>
                                        <ext:ModelField Name="Id" Type="Int" UseNull="true" />
                                        <ext:ModelField Name="CustomerName" Mapping="CustomerName" />
                                       
                                        <ext:ModelField Name="NetsuiteCustomerCode" Mapping="NetsuiteCustomerCode" />
                                      
                                        <ext:ModelField Name="CustomerContactName" />
                                       
    
                                         <ext:ModelField Name="CustomerEmail" />
                                          <ext:ModelField Name="DriverMobileNo" />
                                            <ext:ModelField Name="CustomerFax" />
                                              <ext:ModelField Name="CustomerPhoneOffice" />
                                                <ext:ModelField Name="CustomerContactName" />
                                                 <ext:ModelField Name="CustomerMobile" />
                                                
                                           <ext:ModelField Name="ApplicationRefNo" />
                                             <ext:ModelField Name="CustomerAddress" />
                                                   <ext:ModelField Name="City" />
                                                <ext:ModelField Name="Emirate" />
                                                  <ext:ModelField Name="Country" />
                                                     <ext:ModelField Name="TradeLicenseNo" />
                                                       <ext:ModelField Name="Customertype" Mapping="wmsCustomerTypeMaster.TypeDescription" />
                                                          <ext:ModelField Name="PermitNo" />
                                                             <ext:ModelField Name="Driver" />
                                                           <%--   <ext:ModelField Name="DriverMobileNo" />--%>
    
                                                              <ext:ModelField Name="VehicleType" />
                                                       <ext:ModelField Name="VehicleNo" />
                                                          <ext:ModelField Name="PermitType" />
                                                             <ext:ModelField Name="PermitCategory" />
                                                                <ext:ModelField Name="Status" />
    
                                           
                                    </Fields>
                                </ext:Model>
                            </Model>
            </ext:Store>     
    
    
            
            <ext:GridPanel 
                ID="GridPanel1" 
                runat="server" 
                StoreID="Store7"
                Title="Export Data"
                Width="600" 
                Height="350">
                <ColumnModel ID="ColumnModel2" runat="server">
                    <Columns>
                       <ext:Column ID="Column5" runat="server" Text="ID" Width="40" DataIndex="Id" Hidden="true" />
                            <%--    <ext:Column ID="CustID" runat="server" Text="Customer ApplicationRefNo" DataIndex="ApplicationRefNo"
                                Width="160">
                            </ext:Column>--%>
                            <ext:Column ID="Column7" runat="server" Text="Application RefNo." Width="110"
                                DataIndex="ApplicationRefNo">
                            </ext:Column>
    
                            <ext:Column ID="Column8" runat="server" Text="NetsuiteCode" Width="100"
                                DataIndex="NetsuiteCustomerCode">
                            </ext:Column>
                            
                            <ext:Column ID="Column9" runat="server" Text="Name" Width="140" DataIndex="CustomerName">
                            </ext:Column>
    
                            <ext:Column ID="Column10" runat="server" Text="Type" Width="100" DataIndex="Customertype">
                            </ext:Column>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" Mode="Multi" />
                </SelectionModel>
                
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <ext:ToolbarFill ID="ToolbarFill2" runat="server" />
                            
                            
                            
                            <ext:Button ID="Button2" runat="server" Text="To Excel" AutoPostBack="true" OnClick="ToExcel" Icon="PageExcel">
                                <Listeners>
                                    <Click Fn="saveData" />
                                </Listeners>
                            </ext:Button>
                            
                            
                        </Items>
                    </ext:Toolbar>
                </TopBar>
            </ext:GridPanel>  
    
    
           
       
        </form>
    </body>
    
    
    </html>
    Last edited by Daniil; Jul 23, 2013 at 12:55 PM. Reason: Please use [CODE] tags, [CLOSED]
  2. #2
    Hi @satyadev,

    I could not reproduce.

    To run the test case I had to replace
    Url="~/CustomerRegistrationReport/GetData"
    with some valid URL on my side.

    Though it should not affect the exporting functionality.

    To test I used the latest Ext.NET from the trunk and FireFox.

Similar Threads

  1. Replies: 0
    Last Post: Jan 08, 2013, 5:18 AM
  2. Export to Excel
    By JonC in forum 1.x Help
    Replies: 9
    Last Post: Nov 13, 2012, 4:59 AM
  3. Excel Export
    By maephisto in forum 1.x Help
    Replies: 1
    Last Post: May 13, 2011, 11:47 AM
  4. Export to Excel not working
    By iltwams in forum 1.x Help
    Replies: 0
    Last Post: Sep 29, 2010, 9:16 PM
  5. vb example of export to Excel
    By grosenbrock in forum 1.x Help
    Replies: 2
    Last Post: Aug 27, 2010, 6:22 PM

Tags for this Thread

Posting Permissions