asp.net½«Ò³ÃæÖÐgridviewÖеÄÊý¾Ýµ¼Èëexcel±íÖÐ
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
namespace AJAXEnabledWebApplication1
{
public partial class excelOutput : System.Web.UI.Page
{
DBClass db = new DBClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string strsql = "select * from TreeViewTemp where parentID=0";
DataTable dt = db.GetDataTable(strsql);
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
OutPutExcel();
}
//´Ë´¦Òª×¢Òâ,Õâ¸öÖØÔØ·½·¨,Ò»¶¨ÒªÐ´,²»È»»á±¨ÀàÐÍ“GridView”µÄ¿Ø¼þ“GridView1”±ØÐë·ÅÔÚ¾ßÓÐ runat=server µÄ´°Ìå±ê¼ÇÄÚ
public override void VerifyRenderingInServerForm(Control control)
{
}
public void OutPutExcel()
{
//¶¨ÒåÎĵµÀàÐÍ¡¢×Ö·û±àÂë
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
//ÏÂÃæÕâÐкÜÖØÒª£¬ attachment ²ÎÊý±íʾ×÷Ϊ¸½¼þÏÂÔØ£¬Äú¿ÉÒÔ¸Ä³É onlineÔÚÏß´ò¿ª
//filename=FileFlow.xls Ö¸¶¨Êä³öÎļþµÄÃû³Æ£¬×¢ÒâÆäÀ©Õ¹ÃûºÍÖ¸¶¨ÎļþÀàÐÍÏà·û£¬¿ÉÒÔΪ£º.doc ¡¡¡¡ .xls ¡¡¡¡ .txt ¡¡¡¡.htm
Response.AppendHeader("Content-Disposition", "attachment;filename=FileFlow.xls");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
//Response.ContentTypeÖ¸¶¨ÎļþÀàÐÍ ¿ÉÒÔΪapplication/ms-excel¡¢application/ms-word¡¢application/ms-txt¡¢application/ms-html »òÆäËûä¯ÀÀÆ÷¿ÉÖ±½ÓÖ§³ÖÎĵµ
Ïà¹ØÎĵµ£º
1.//µ¯³ö¶Ô»°¿ò.µã»÷תÏòÖ¸¶¨Ò³Ãæ
Response.Write(" <script>window.alert('¸Ã»áԱûÓÐÌá½»ÉêÇë,ÇëÖØÐÂÌá½»£¡')
</script>");
Response.Write(" <script>window.location
='http://www.51aspx.com/bizpulic/upmeb.aspx' </script>");
2.//µ¯³ö¶Ô»°¿ ......
Beyond File | New Company: from Cheesy Sample to Social Platform Scott Hanselman in Lagoon L on Monday at 11:30 AM The web has changed and there's a new way of thinking about your applications. You can't just write some HTML and CSS anymore and expect to be the next Twitter. Hear h ......
Online active users counter in ASP.NET
With this tool which is written for ASP.NET, it is possible to count the number of online users, members and guest users in web sites.
Installation
The tool installation is very simple and only takes a few minutes.
Step one - Add Reference:
After downlo ......
×î½üÔÚ¿´¡¶asp.netͨÓÃÄ£¿é¼°µäÐÍϵͳ¿ª·¢ÊµÀýµ¼º½¡·£¬ÆäÖÐÓõ½ÁËMD5¼ÓÃÜ£¬´úÂëÈçÏ£º /// <summary>
/// ×Ö·û´®¼ÓÃܺ¯Êý
/// </summary>
/// <param name="strInput">ÊäÈë±»¼ÓÃܵÄ×Ö·û´®</param>
/// <returns>¼ÓÃܺóµÄ×Ö·û´®</return ......
ÔÚÒ»¸öСÐÍÏîÄ¿ÖУ¬ÎÒʹÓÃÁËAjax ExtensionsÖеÄUpdatePanel¿Ø¼þ£¬ÔÚ±¾µØµ÷ÊÔÔËÐÐʱºÃµÄ£¬¿ÉÒÔ¿´µ½ajaxµÄÒ첽ˢÐÂЧ¹û£¬µ«Êǵ±·¢²¼µ½°²×°ÁË.net framework 3.5 sp1µÄserver 2003ÉÏÈ¥Ö®ºó£¬·¢ÏÖajaxЧ¹ûûÓÐÁË£¬Ò²¾ÍÊÇ˵±¾À´µÄÒì²½Ìá½»±ä³ÉÁË·ÇAjax·½Ê½µÄPOST£¬¶øÇÒûÓб¨¸æÈκδíÎó¡£
¶Ô±È¿ª·¢Ê±ºÍÔËÐÐ ......