Export grid panel data to excel

  1. #1

    Export grid panel data to excel

    Hi ,

    Im using a grid panel with a large number of templated columns. i want to export the same grid to excel , whereas the format needs to be retained..

    I tried using several samples .. but it exports the store data alone.. the format of the grid is not available..


    Pls help me to export my ext grid panel to excel with the format , what i have designed to show in UI
  2. #2
    Quote Originally Posted by sumesh View Post
    Hi ,

    Im using a grid panel with a large number of templated columns. i want to export the same grid to excel , whereas the format needs to be retained..

    I tried using several samples .. but it exports the store data alone.. the format of the grid is not available..


    Pls help me to export my ext grid panel to excel with the format , what i have designed to show in UI

    HI you can use this code


    protected void Store1_Submit(object sender, StoreSubmitDataEventArgs e)
    {
    string format = this.FormatType.Value.ToString();

    XmlNode xml = e.Xml;

    this.Response.Clear();




    this.Response.ContentType = "application/vnd.ms-excel";
    this.Response.AddHeader("Content-Disposition", "attachment; filename=File.xls");
    System.Xml.Xsl.XslCompiledTransform xtExcel = new System.Xml.Xsl.XslCompiledTransform();
    xtExcel.Load(Server.MapPath("Excel.xsl"));
    xtExcel.Transform(xml, null, Response.OutputStream);
    this.Response.End();

    }

    Javascript
    ********************************
    var submitValue = function (grid, hiddenFormat, format) {
    hiddenFormat.setValue(format);
    grid.submitData(false, { isUpload: true });
    };


    design
    *****************
    <ext:Hidden ID="FormatType" runat="server" />


    InStore
    *****************
    OnSubmitData="Store1_Submit"




    <TopBar>
    <ext:Toolbar ID="Toolbar1" runat="server">
    <Items>
    <ext:ToolbarFill ID="ToolbarFill1" runat="server" />


    <ext:Button ID="Button3" runat="server" Text="To Excel" Icon="PageExcel">
    <Listeners>
    <Click Handler="submitValue(#{GridPanel1}, #{FormatType}, 'xls');" />
    </Listeners>
    </ext:Button>


    </Items>
    </ext:Toolbar>
    </TopBar>

Similar Threads

  1. Export to excel: Grid Panel with multiple pages.
    By breakyoheart in forum 2.x Help
    Replies: 0
    Last Post: Aug 02, 2012, 8:09 PM
  2. Replies: 1
    Last Post: May 28, 2012, 5:17 AM
  3. Export grid panel data to excel
    By sumesh in forum 1.x Help
    Replies: 0
    Last Post: May 19, 2012, 6:01 AM
  4. Export data to excel - in order columns
    By tanju_yayak in forum 1.x Help
    Replies: 2
    Last Post: Mar 22, 2012, 6:40 AM
  5. Data Export Excel Column Names
    By BLOZZY in forum 1.x Help
    Replies: 0
    Last Post: Feb 02, 2012, 2:02 PM

Posting Permissions