C# ½«Êý¾Ýµ¼³öµ½Execl»ã×Ü
×î½üÔÚÕÒÊý¾Ýµ¼³öµ½EXCELµÄ·½·¨£¬·¢ÏÖÖñÁÖbat800ÔÚblogÖз¢²¼µÄ·½·¨£¬ÎªÁ˱ãÓÚÒÔºó²éÕÒתµ½×Ô¼ºblogÏÂ
http://blog.csdn.net/bat800/archive/2007/07/17/1694537.aspx
ÕâÊÇÔÎĵØÖ·
Ò»¡¢asp.netÖе¼³öExeclµÄ·½·¨£º
ÔÚasp.netÖе¼³öExeclÓÐÁ½ÖÖ·½·¨£¬Ò»ÖÖÊǽ«µ¼³öµÄÎļþ´æ·ÅÔÚ·þÎñÆ÷ij¸öÎļþ¼ÐÏÂÃ棬Ȼºó½«ÎļþµØÖ·Êä³öÔÚä¯ÀÀÆ÷ÉÏ£»Ò»ÖÖÊǽ«ÎļþÖ±½Ó½«ÎļþÊä³öÁ÷д¸øä¯ÀÀÆ÷¡£ÔÚResponseÊä³öʱ£¬t·Ö¸ôµÄÊý¾Ý£¬µ¼³öexeclʱ£¬µÈ¼ÛÓÚ·ÖÁУ¬nµÈ¼ÛÓÚ»»ÐС£
1¡¢½«Õû¸öhtmlÈ«²¿Êä³öexecl
´Ë·¨½«htmlÖÐËùÓеÄÄÚÈÝ£¬Èç°´Å¥£¬±í¸ñ£¬Í¼Æ¬µÈÈ«²¿Êä³öµ½ExeclÖС£
Response.Clear();
Response.Buffer= true;
Response.AppendHeader("Content-Disposition","attachment;filename="+DateTime.Now.ToString("yyyyMMdd")+".xls");
Response.ContentEncoding=System.Text.Encoding.UTF8;
Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
ÕâÀïÎÒÃÇÀûÓÃÁËContentTypeÊôÐÔ£¬ËüĬÈϵÄÊôÐÔΪtext/html£¬Õâʱ½«Êä³öΪ³¬Îı¾£¬¼´ÎÒÃdz£¼ûµÄÍøÒ³¸ñʽµ½¿Í»§¶Ë£¬Èç¹û¸ÄΪms-excel½«½«Êä³öexcel¸ñʽ£¬Ò²¾ÍÊÇ˵ÒÔµç×Ó±í¸ñµÄ¸ñʽÊä³öµ½¿Í»§¶Ë£¬Õâʱä¯ÀÀÆ÷½«ÌáʾÄãÏÂÔر£´æ¡£ContentTypeµÄÊôÐÔ»¹°üÀ¨£ºimage/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword ¡£Í¬Àí£¬ÎÒÃÇÒ²¿ÉÒÔÊä³ö(µ¼³ö)ͼƬ¡¢wordÎĵµµÈ¡£ÏÂÃæµÄ·½·¨£¬Ò²¾ùÓÃÁËÕâ¸öÊôÐÔ¡£
2¡¢½«DataGrid¿Ø¼þÖеÄÊý¾Ýµ¼³öExecl
ÉÏÊö·½·¨ËäȻʵÏÖÁ˵¼³öµÄ¹¦ÄÜ£¬µ«Í¬Ê±°Ñ°´Å¥¡¢·ÖÒ³¿òµÈhtmlÖеÄËùÓÐÊä³öÐÅÏ¢µ¼Á˽øÈ¥¡£¶øÎÒÃÇÒ»°ãÒªµ¼³öµÄÊÇÊý¾Ý£¬DataGrid¿Ø¼þÉϵÄÊý¾Ý¡£
System.Web.UI.Control ctl=this.DataGrid1;
//DataGrid1ÊÇÄãÔÚ´°ÌåÖÐÍϷŵĿؼþ
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.Cur
Ïà¹ØÎĵµ£º
ÔÚasp.net開發ÖУ¬經³£會Óõ½áą́ºÍǰ̨µÄ½»»¥£¬¾Í´Ë總結ÁËÒ»點c#ºÍjavascriptÏ໥²Ù×÷µÄ·½·¨
¡¡¡¡1.ÔÚáą́c#´ú碼ÖÐ調ÓÃjacascriptµÄ·½·¨
¡¡¡¡javascript´ú碼£º
¡¡¡¡<script type="text/javascript" language="javascript">
¡¡¡¡function test()
¡ ......
ÎÄÕÂÀ´Ô´£ºIT¹¤³Ì¼¼ÊõÍø http://www.systhinker.com/html/43/n-11643.html
ÓõÄÊÇÒ»Öֺܱ¿µÄ·½·¨£¬µ«¿ÉÒÔ°ïÖú³õѧÕßÁ˽â·ÃÎÊXML½ÚµãµÄ¹ý³Ì¡£
ÒÑÖªÓÐÒ»¸öXMLÎļþ£¨bookstore.xml£©ÈçÏÂ:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
......
ʹÓÃc#ÓïÑÔÔÚ.netƽ̨Éú³ÉµÄdllÊÇ»ùÓÚMSILµÄ¶þ½øÖÆ´úÂ룬ͨ³£Çé¿öÏÂÊÇÎÞ·¨±»nativeµÄÓïÑԺͳÌÐòµ÷Óõģ¨ÀýÈçvb£¬vc£¬delphi£©¡£µ«ÊÇÒ»°ãÀ´ËµwindowsÉÏnativeµÄ³ÌÐò¶¼ÊÇ¿ÉÒÔÖ±½ÓʹÓÃcom¶ÔÏóµÄ¡£Í¨¹ý.netƽ̨ÌṩµÄһЩ¹¤¾ß£¬¿ÉÒÔΪÆäαÔìÒ»¸öcom½Ó¿Ú²¢×¢²áµ½ÏµÍ³ÖС£´Ëʱ£¬¿ÉÒÔÔÚnativeµÄ³ÌÐòÀͨ¹ýÕâ¸öαcom½Ó¿ÚÀ´ÊµÏÖ´Ë. ......
ÒªÔÚJavaÖлñµÃijһ±äÁ¿µÄËø£¬±ØÐëÔÚ´úÂëµÄÊ×β¶þ¶Ë¼ÓÉÏsynchronized¹Ø½¡×Ö£¬Ö¸Ã÷ÐèÒª»ñµÃËøµÄ¶ÔÏó¡£Ò»µ©Ï߳̿ªÊ¼Ö´ÐÐsynchronized¿éÖеĴúÂ룬Ëü¾Í»ñµÃÁ˶ÔÕâÒ»¶ÔÏóµÄËøµÄ¿ØÖÆȨ¡£Í¬Ñù£¬Ò»µ©Ïß³ÌÒѾÀ뿪ÁËsynchronized¿é£¬ËüÒ²½«ÊÍ·ÅÕâÒ»¶ÔÏóµÄËø¡£ÎÒÃÇÒѾ֪µÀ£¬C#Ò²ÓÐÒ»¸öÏàËƵı»³Æ×÷lockµÄ¹Ø½¡×Ö¡£³ýÁËlockÕâ¸ö¹Ø½¡×Ö ......
ASP.NET(C#)·µ»ØÉÏÒ»Ò³(ºóÍË)´úÂë
2008-08-10 10:32
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["BackUrl"] = Request.UrlReferrer.ToString();
}
}
/// <s ......