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

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


Ïà¹ØÎĵµ£º

C#¹ØÓÚsqlserverÖжÁÈ¡imageÀàÐÍ

½ñÌìÔÚÍøÉÏÕÒÁËÐí¾Ã¹ØÓÚsqlserverÖд洢imageÀàÐͺͶÁÈ¡imageµÄ·½·¨£¬¿ÉÊǶ¼ÊÇÄÇôһµã£¬¹ÊÔÚ´ËÂÞÁÐһϣ¬Ï£Íû¿ÉÒÔ°ïÖú´ó¼Ò¡£
Ê×ÏÈÊǹØÓÚdataGridViewµÄ°ó¶¨¡£´úÂë¼ûÏÂ
private void button_show_Click(object sender, EventArgs e)
{
string sqlText = "server=localhost;initial catalog=Test; ......

ASP.NET(C#)·µ»ØÉÏÒ»Ò³(ºóÍË)´úÂ루תÔØ£©

ASP.NET(C#)·µ»ØÉÏÒ»Ò³(ºóÍË)´úÂë
2008-08-10 10:32
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        ViewState["BackUrl"] = Request.UrlReferrer.ToString();
    }
}
/// <s ......

c# sqlite Êý¾Ý¿â¼ÓÃÜ


ÓÃÁËADO.NET 2.0 SQLite Data Provider ÕâÑù¿ÉÒÔÖ±½ÓÀûÓÃËüÀ´´´½¨Ò»¸ö¼ÓÃܵÄsqliteÊý¾Ý¿â¡£
ÓйØc#´úÂëÈçÏ£º
1¡¢´´½¨¿ÕµÄsqliteÊý¾Ý¿â¡£
//Êý¾Ý¿âÃûµÄºó׺Äã¿ÉÒÔÖ±½ÓÖ¸¶¨£¬ÉõÖÁûÓкó׺¶¼¿ÉÒÔ
//·½·¨Ò»£º´´½¨Ò»¸ö¿ÕsqliteÊý¾Ý¿â£¬ÓÃIOµÄ·½Ê½
FileStream fs = File.Create(“c:\\test.db“);
//·½·¨¶þ£ºÓ ......

C#Á¬½ÓsqlserverÊý¾Ý¿â


       µ±ÔÚC#ÓïÑÔÖУ¬Á¬½ÓsqlÊý¾Ý¿âµÄʱºò£¬³£Óõ½sqlconnection½¨Á¢ÓëÊý¾Ý¿âµÄÁ¬½Ó¡£ Óï·¨ÈçÏ£º
       String sqlcon = "***";//ÕâÀïÊÇÒ»¸ö×Ö·û´®£¬¾ßÌå¸úÊý¾Ý¿âµÄÑéÖ¤·½Ê½Óйء£
//sql server Éí·ÝÑéÖ¤ Á¬½Ó×Ö·û´®
private string ConnstrSqlServer = "server=·þÎñÆ÷Ãû³ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ