473,385 Members | 1,922 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,385 software developers and data experts.

Generating Excel replorts of a gridview

103 100+
Hi all,

I would like to generate reports of a gridview in excel format using asp.net and c#.net

Please help me,,,

Thanks and regards,
Mathew.
Oct 8 '07 #1
1 900
mathewgk80
103 100+
Hi all,

I would like to generate reports of a gridview in excel format using asp.net and c#.net

Please help me,,,

Thanks and regards,
Mathew.

Hi all.
I got the answer for the topic..

The code is:

protected void Button1_Click(object sender, EventArgs e)
{
try
{
Response.Clear();
Response.AddHeader("Content-Disposition", "inline;filename=test.xls");
Response.Charset = "iso-8859-1, windows-1252 ";
Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.ContentType = "application/vnd";
this.EnableViewState = false;
StringWriter StringWriter = new StringWriter();
System.Web.UI.HtmlTextWriter htmltextwriter = new System.Web.UI.HtmlTextWriter(StringWriter);
GridView1.RenderControl(htmltextwriter);
Response.Write(StringWriter.ToString());
Response.End();
}
catch
{

}
}


Thanks and regards,

Mathew
Oct 8 '07 #2

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

Similar topics

3
by: daniele.balducci | last post by:
Hi All, I'm generating XLS files from ASP(.Net) code using the usual code chunks ... Response.ContentType = "application/vnd.ms-excel" Response.AppendHeader("Content-Disposition", "attachment;...
3
by: Seagull Ng | last post by:
Hello all, I am doing my web-based reporting tool in ASP.Net 2.0 using Visual Web Developer 2005. I try to export my populated gridview to Excel spreadsheet but what I got is just a blank...
1
by: Andrew Nav | last post by:
I dragged a table from a datasource on to my web form and the GridView cpntrol was created. I turned on paging, and Edit and Delete buttons. I ran the app and everything worked great - not a...
3
by: =?Utf-8?B?bWFuaWthMDI=?= | last post by:
Hi, I have a GridView control in page called eventslisting which is inheriting from a MasterPage. The normal code to export to GridView does not work and gives me an error - "Control of type...
0
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have a gridview. I calculated some values in the gridview for the footer of the gridview so basically I am adding all the values that are displayed in the gridview for each...
6
by: Sergio E. | last post by:
Hi, I'm looking for information about gridview's cell properties... I've the following case: one gridview with alternatirg row style and normalrowstyle, 3 o 4 custom styles that are applied to...
1
by: edwinparker | last post by:
Hi, I'm trying to convert a gridview to an excel report and have one small hang up. So far I've been able to create my gridview and export it to excel ok, but in my gridview I have an image. The...
1
by: Yordan Georgiev | last post by:
I have a search form using master page , which is dynamically generated from the column names of the database - when the users have a search result it should be exported to Excel by clicking the...
6
by: vinod allapu | last post by:
Hi boss, I have a gridview, bound to a datasource . Here i want to add columns dynamically containing empty textboxes. Number of columns are variant . The added columns are not bound to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.