473,386 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to export datagridview to excel?

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?
May 3 '07 #1
7 14565
dip_developer
648 Expert 512MB
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...
May 3 '07 #2
hai,
below is the link to Export ASP.NET DataGrid to Excel
link
and hope this helps you
May 3 '07 #3
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");


}
May 3 '07 #4
you can try this link
http://www.thescripts.com/forum/thread637955.html
May 3 '07 #5
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.
May 8 '07 #6
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.
Aug 20 '07 #7
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.

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?
Nov 30 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table....
13
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"...
0
by: artteam | last post by:
Hi All, I try to export the table in DataGridView control on my form to MS excel with the following code. private void fnExtractToExcel() { ...
2
by: Mike Wilson | last post by:
Dear all, I'm sure someone has already done this, so as not to wish to re-invent the wheel - and Google not turning up anything I can use, does anyone have a suitable function into which I can...
5
by: Mike Wilson | last post by:
Hello all, I'd like to export a DataGridView to Excel. I am using .NET 2.0 and VB.NET. But I don't know if the user has Excel on their machines, so can't use COM Excel object. Any ideas...
0
by: nitin005 | last post by:
I have to export the data present in the datagridview to Microsoft Excel. It is a window application using c#. Does anyone know how to do it. Please help. Thanks
19
by: cj2 | last post by:
#1 Is there a quick way to export a datatable to an excel file? Or delimited file? #2 Where is the appropriate Microsoft monitored group to ask about writing reports in SQL Reporting services...
2
by: ISATownsME | last post by:
Hello, I have a program that loads a datagridview from excel to visual studio. Can anyone tell me how to export the cell values of the datagridview to my access database?
2
by: Narz1986 | last post by:
hi...i m trying to export data from the datagrid to excel...here is my code HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("content-disposition",...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.