c#转Exce问题
 private   void   Excel() 
       {						 
                Response.Clear(); 
                           Response.Buffer=   true; 
                           Response.Charset= "GB2312 ";  			 
                                  Response.AppendHeader( "Content-Disposition ", "attachment;filename=FileFlow.xls "); 
                           Response.ContentEncoding=System.Text.Encoding.GetEncoding( "GB2312 ");                             
                           Response.ContentType   =    "application/ms-excel "; 
                           this.EnableViewState   =   false;  			 
                           System.IO.StringWriter   oStringWriter   =   new   System.IO.StringWriter(); 
                           System.Web.UI.HtmlTextWriter   oHtmlTextWriter   =   new   System.Web.UI.HtmlTextWriter(oStringWriter);   
 			this.RenderControl(oHtmlTextWriter);                          
                           Response.Write(oStringWriter.ToString()); 
                           Response.End(); 
 		}
------解决方案--------------------?
------解决方案--------------------导出 
 protected void Button1_Click(object sender, EventArgs e) 
     { 
         Export( "application/ms-excel ",  "学生成绩报表.xls "); 
     }   
     private void Export(string FileType, string FileName) 
     { 
         Response.Charset =  "GB2312 "; 
         Response.ContentEncoding = System.Text.Encoding.UTF7; 
         Response.AppendHeader( "Content-Disposition ",  "attachment;filename= " + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString()); 
         Response.ContentType = FileType; 
         this.EnableViewState = false; 
         StringWriter tw = new StringWriter(); 
         HtmlTextWriter hw = new HtmlTextWriter(tw); 
         GridView1.RenderControl(hw); 
         Response.Write(tw.ToString()); 
         Response.End(); 
     }   
------解决方案--------------------什么叫 "以上的代碼是把整個web頁面导出了Excel 。 
 請教:怎么把数据库查询出的资料导成excel?謝謝 ! "   
 你想从数据库里查询出来就导成excel的话,你直接用查询分析器好了啊,你手动复制一下,打开一个excel,粘贴一下就可以了,呵呵.参考以下的页面,有好多. 
 http://www.yxsoft.net.cn/Article/aspnet2/200705/492.html