Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

asp.net C# ½«Êý¾Ýµ¼³öµ½Execl»ã×Ü


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.Current.Response.ContentType ="application/ms-excel";
ctl.Page.EnableViewState =false;   
System.IO.StringWriter tw = new System.IO.StringWriter() ;
System.Web.UI.Ht


Ïà¹ØÎĵµ£º

ASP.NET MVC ѧϰÌù

1. µ±ÔÚÒ»¸ö Action ÖÐ ¶ÔÏàͬ¹¦ÄܵÄ2¸ö¿Ø¼þ½øÐи³Öµ 
     List<SelectListItem> WebSite = GetWebSite();
ViewData["SiteNames"] = WebSite;
if (WebSite.Count > 0)
WebSite.RemoveAt(0);
ViewData["SiteName"] = WebSite;
   Ò³ÃæÏÔʾʱ»áͳһÒÔ WebSite ......

ASP.NETÖÐÈÃͼƬÒÔ¶þ½øÖƵÄÐÎʽ´æ´¢ÔÚÊý¾Ý¿âÖÐ


 ½ñÔçÓиöÍøÓÑÎʵ½ÎÒÕâÎÊÌ⣬ÒÔÇ°ÎÒ¶¼ÊÇÖ±½ÓÔÚÊý¾Ý¿âÖдæÎļþÃûµÄ£¬»¹Ã»ÓÐÊÔ¹ý´æ´¢ÕûÕÅͼƬµ½Êý¾Ý¿âÖУ¬ÉÏÍøËÑË÷ÁËһϣ¬×Ô¼ºÓÖ²âÊÔÁËÒ»·¬£¬´úÂëÈçÏ£º
½¨Á¢±£´æͼƬµÄ±íµÄSQLÓï¾ä£º
 
Sql´úÂë < width="14" height="15" src="javascripts/syntaxhighlighter/clipboard_new.swf" pluginspage="http://w ......

C# ÓÃSQLн¨Êý¾Ý¿â

1. ³ÌÐòÈçÏ£º
         string str = "Create Database " + "DBname";
         string con = "Data Source=10.0.0.249\\sql2005;Initial Catalog=master;Persist Security Info=True;User ID=sa;Password=sa";
   &n ......

c#ºÍjavascript½»»¥

ÔÚasp.net開發ÖУ¬經³£會Óõ½áą́ºÍǰ̨µÄ½»»¥£¬¾Í´Ë總結ÁËÒ»點c#ºÍjavascriptÏ໥²Ù×÷µÄ·½·¨
¡¡¡¡1.ÔÚáą́c#´ú碼ÖÐ調ÓÃjacascriptµÄ·½·¨
¡¡¡¡javascript´ú碼£º
¡¡¡¡<script type="text/javascript" language="javascript">
¡¡¡¡function test()
¡ ......

C#ÖвÙ×÷XML Node½Úµãϸ½Ú²Ù×÷

ÓõÄÊÇÒ»Öֺܱ¿µÄ·½·¨£¬µ«¿ÉÒÔ°ïÖú³õѧÕßÁ˽â·ÃÎÊXML½ÚµãµÄ¹ý³Ì¡£
ÒÑÖªÓÐÒ»¸öXMLÎļþ£¨bookstore.xml£©ÈçÏÂ:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
  <book genre="fantasy" ISBN="2-3631-4">
    <title>Oberon's Legacy</title>
  &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ