亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

asp.net導(dǎo)出EXCEL的功能代碼

 更新時間:2008年07月11日 08:53:52   作者:  
這是一段網(wǎng)上很多人使用的導(dǎo)出EXCEL代碼,但使用過程中發(fā)現(xiàn)很多不足的地方,其不用引入其它控件。
復(fù)制代碼 代碼如下:

//由gridviw導(dǎo)出為Excel
public static void ToExcel(System.Web.UI.Control ctl)
{
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=Excel.xls");
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType = "application/ms-excel";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
ctl.Page.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}


這是一段網(wǎng)上很多人使用的導(dǎo)出EXCEL代碼,但使用過程中發(fā)現(xiàn)很多不足的地方,其不用引入其它控件。
缺點:
1、我采用ASPNETPAGER分頁時只能導(dǎo)出第一頁。
2、使用十分不靈活,對樣式的控制,字段的控制不靈活。

使用中需要注意:
1、 <%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeFile="Default.aspx.cs" Inherits="_Default"%>
加上這句。

2、在后臺文件中加上:
public override void VerifyRenderingInServerForm(Control control)
{

 }
3、需引入 using System.IO;

其它相關(guān)文章:
ASP.NET操作Excel備忘錄 
ASP.net連接Excel的代碼
asp.net 讀取并顯示excel數(shù)據(jù)的實現(xiàn)代碼
在Asp.net用C#建立動態(tài)Excel
asp.net 操作excel的實現(xiàn)代碼

相關(guān)文章

最新評論