Connecting Tech Pros Worldwide Forums | Help | Site Map

How to export datagridview to excel?

Newbie
 
Join Date: Apr 2007
Location: North
Posts: 10
#1: May 3 '07
Hi, anyone know how can i export the information in the datagridview to an Excel file?

i understand that the crystal report tool has such a build in function for importing to pdf or execl, then how can i convert the information in datagrid to a crystral report?

dip_developer's Avatar
Expert
 
Join Date: Aug 2006
Location: Asansol
Posts: 641
#2: May 3 '07

re: How to export datagridview to excel?


Quote:

Originally Posted by RafaulWolf

Hi, anyone know how can i export the information in the datagridview to an Excel file?

i understand that the crystal report tool has such a build in function for importing to pdf or execl, then how can i convert the information in datagrid to a crystral report?

Dont you know how to create a Crystal report......by which means data are binded to report......Let us know how much do u know about crystal report....otherwise you have to learn about Push and Pull methods of crystal report.......which cant be explained in short...
Member
 
Join Date: Jan 2007
Posts: 52
#3: May 3 '07

re: How to export datagridview to excel?


hai,
below is the link to Export ASP.NET DataGrid to Excel
link
and hope this helps you
Newbie
 
Join Date: Mar 2007
Posts: 1
#4: May 3 '07

re: How to export datagridview to excel?


i think this can help you
protected void Exl_Click(object sender, EventArgs e)
{
Exl.Visible = false;
Wrd.Visible = false;
TextBox1.Visible = false;
srh.Visible = false;//GridView2.Font.Size = 15;
//GridView1.PagerSettings.Visible = true;
//Image2.Visible = true;
Response.Clear();

Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");

Response.Charset = "";

// If you want the option to open the Excel file without saving than

// comment out the line below

Response.Cache.SetCacheability(HttpCacheability.No Cache);

Response.ContentType = "application/vnd.xls";

System.IO.StringWriter stringWrite = new System.IO.StringWriter();

System.Web.UI.HtmlTextWriter htmlWrite =
new HtmlTextWriter(stringWrite);

// turn off paging
GridView2.AllowPaging = false;

DataSet myDAtaset1 = dataset1();



GridView2.DataSource = myDAtaset1;
GridView2.DataBind();



GridView2.RenderControl(htmlWrite);

Response.Write(stringWrite.ToString());

Response.End();
Response.Redirect(@"Default.aspx");


}
Member
 
Join Date: Jan 2007
Posts: 52
#5: May 3 '07

re: How to export datagridview to excel?


you can try this link
http://www.thescripts.com/forum/thread637955.html
Newbie
 
Join Date: Apr 2007
Location: North
Posts: 10
#6: May 8 '07

re: How to export datagridview to excel?


Quote:

Originally Posted by dip_developer

Dont you know how to create a Crystal report......by which means data are binded to report......Let us know how much do u know about crystal report....otherwise you have to learn about Push and Pull methods of crystal report.......which cant be explained in short...


I'm just a beginner in VB and i'm doing a project for my attractment company. Basically, my understanding of crystal report is that i can drag the Report viewer from the toolbox and create a new report by binding it to my data source.BUT this will show all the data in the database

However, my application require me to export the excat information from the datagridview as i have insert Sql statement to query my seach result.

Do you know of link to example in VB.net or VB. Cos the other rely i received are all examples in Visual C# which i'm not familiar with.
Newbie
 
Join Date: Aug 2007
Posts: 3
#7: Aug 20 '07

re: How to export datagridview to excel?


Quote:

Originally Posted by ashasprabhu

hai,
below is the link to Export ASP.NET DataGrid to Excel
link
and hope this helps you

Hi folks - the post is usefull. If you want to export an DataGridView control's data and visualization to excel or html you can use DataGridView Extension ...
see http://www.completit.com/Products/DGVE/Overview.aspx
it is free. Also it gives an additional functionality of the basic control for searching for text, theme management and many more. Hope it will help you.
Newbie
 
Join Date: Aug 2007
Posts: 3
#8: Nov 30 '07

re: How to export datagridview to excel?


There is a free component doing exporting to excel, html and pdf ... see http://www.completit.com/Products/DGVE/Overview.aspx for more information ... i thing the component is great and the most important - it's free.

Quote:

Originally Posted by RafaulWolf

Hi, anyone know how can i export the information in the datagridview to an Excel file?

i understand that the crystal report tool has such a build in function for importing to pdf or execl, then how can i convert the information in datagrid to a crystral report?

Reply