Current location: Hot Scripts Forums » Programming Languages » ASP.NET » Export grdiview to excel problem


Export grdiview to excel problem

Reply
  #1 (permalink)  
Old 07-24-09, 04:59 AM
arny1 arny1 is offline
Newbie Coder
 
Join Date: Jul 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Export grdiview to excel problem

Hi There,

I had this post before,but I have some problems when I add a header for specific charcter set,and also add some additional data,

here is my code;

Code:
 
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=aname.xls");
 
string header = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<title></title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1254\" />\n<style>\n</style>\n</head>\n<body>\n";
 
Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254"); Response.Charset = "windows-1254"; //ISO-8859-9 windows-1254
Response.ContentType = "application/vnd.ms-excel";
 
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw); 
 
gvMaster.AllowPaging = false;
gvMaster.RenderControl(hw); //write the output
Response.Output.Write(header.ToString());
Response.Output.Write("Some title\n");
 
Response.Output.Write("\n");
 
//to write current date and time
System.DateTime tDate1 = System.DateTime.Now;
Response.Output.Write(tDate1);
Response.Output.Write("\n");
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
The problem is when I add header next Line is not working and the Title and system time are all in one row,

My question is how can I write the gridview to specific row in output excel or how can I add some line on top of gridview and also how can I add some style to title?

Thanks in advance

Last edited by digioz; 07-27-09 at 09:20 PM.
Reply With Quote
Reply

Bookmarks

Tags
export, grdiview, problem, to excel


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
click in image then export to excel angela ASP 4 09-02-10 05:55 AM
Export to Excel from Database and embedding Word File as well asifrizvi ASP 0 08-22-07 06:06 PM
Excel worksheet problem sujata_ghosh Visual Basic 0 12-21-06 01:06 AM
Export Mysql to Excel mcrob PHP 8 07-12-05 06:49 AM
Export to excel file asp traceMe ASP 2 08-01-04 09:07 PM


All times are GMT -5. The time now is 02:41 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.