none
How to export GridView data to excel in asp.net in C# :

    Question

  • How to export GridView data to excel in asp.net in C#  

    http://qutubhaider.blogspot.in/2013/08/how-to-export-gridview-data-to-excel-in.html

    • Edited by QutubHaider Tuesday, August 27, 2013 8:42 AM
    Tuesday, August 27, 2013 8:40 AM

Answers

All replies

  • Hello QutubHaider,

    Welcome to the MSDN forum.

    You can refer to the following code sample:

    Export Gridview Data to Excel in ASP.NET: http://www.codeproject.com/Tips/477436/Export-Gridview-Data-to-Excel-in-ASP-NET

    For more details, I would recommend you ask on http://forums.asp.net/. It is a good forum for web applications which may help you start.

    Regards,


    Barry Wang
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, August 28, 2013 1:42 AM
  • Try This small demo this will help you http://fantasyaspnet.blogspot.in/2014/02/how-to-export-data-from-gridview-to.html
    Wednesday, February 26, 2014 12:39 PM
  • Export gridview to Excel....

    Gridview to Excel

    Bona

    Tuesday, March 11, 2014 6:53 AM
  • Here is my solution which is based on a .NET Dataexport component

    step1,load data information

    private void btnLoad_Click(object sender, EventArgs e)
    {
       using(OleDbConnection oleDbConnection = new OleDbConnection())
       {
           oleDbConnection.ConnectionString = this.textBox1.Text;
           OleDbCommand oleDbCommand = new OleDbCommand();
           oleDbCommand.CommandText = this.textBox2.Text;
           oleDbCommand.Connection = oleDbConnection;
           using(OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand))
      {
              DataTable dt = new DataTable();
              da.Fill(dt);
              dataGridView1.DataSource = dt;
       }
     }
    }

    step2,set export into excel

    private void btnRun_Click(object sender, EventArgs e)
    { 
      Spire.DataExport.XLS.CellExport cellExport = new Spire.DataExport.XLS.CellExport();
      Spire.DataExport.XLS.WorkSheet worksheet1 = new Spire.DataExport.XLS.WorkSheet();
      worksheet1.DataSource =Spire.DataExport.Common.ExportSource.DataTable;
      worksheet1.DataTable = this.dataGridView1.DataSource as DataTable;
      worksheet1.StartDataCol = ((System.Byte)(0));
      cellExport.Sheets.Add(worksheet1);
      cellExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
      cellExport.SaveToFile("20110223.xls");1
    }

    Hope it helps.To get more detail plz refer this arcticle

    • Edited by Jerk934 Wednesday, April 02, 2014 2:37 AM
    Wednesday, April 02, 2014 2:06 AM