C#Öн«¿Ø¼þÊý¾Ýµ¼³öExcel
ÔÚasp.netÏîÄ¿ÖеÄÒ»¸ö°ÑÊý¾Ý µ¼³öExcel±í¸ñµÄСʼþÈçÏ£º
protected void ibnOut_Click(object sender, ImageClickEventArgs e)//µ¼³öExcel°´Å¥µÄµã»÷ʼþ
{
GridView2.DataSource = dt;//dtÊDzéѯ³öµÄ½á¹û¼¯
GridView2.DataBind();
Response.Clear();
Response.Buffer = true;
Response.Charset = "UTF-8";
Response.AppendHeader("Content-Disposition", "attachment;filename=FileName.xls");
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "application/ms-excel";//ÉèÖÃÊä³öÎļþÀàÐÍΪexcelÎļþ¡£
GridView2.Visible = true;//ÉèÖóÉtrue²ÅÄÜÏÔʾд³ö ±ê¼ÇA
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.GridView2.RenderControl(oHtmlTextWriter);
Ïà¹ØÎĵµ£º
1¡¢Ð½¨Ò»¸öÀà¿âÏîÄ¿
2¡¢½«Class1.cs¸ÄΪÎÒÃÇÏëÒªµÄÃû×Ö
ÎÊÊÇ·ñͬʱ¸øÀà¸ÄÃû£¬È·¶¨
3¡¢ÐÞ¸ÄPropertiesĿ¼ÏÂÃæµÄAssemblyInfo.cs
ComVisibleÊôÐÔÉèÖÃΪTrue
4¡¢ÏîÄ¿²Ëµ¥->MyLibÊôÐÔ
ÕÒµ½“Éú³É”Ñ¡Ï
ÍùÏ¿´£¬ÕÒµ½“Ϊ COM Interop ×¢²á”¹´ÉÏ
5¡¢¼ÌÐøÍùÏ£¬ÕÒµ½“Ç©Ãû&rdqu ......
using System.Data.SqlClient;
using System.Data.OleDb;
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection conn = null;
try
&nbs ......
һֱûÓÐÕÒµ½Ò»Öֺõķ½·¨À´ÒýÓÃÓзµ»ØÖµµÄ´æ´¢¹ý³ÌµÄ·½·¨£¬Ê¹ÎÒÔÚÌí¼ÓÊý¾ÝÖÐ×ßÁ˲»ÉÙµÄÍä·£¬×î½ü£¬ÔÚ²éÔÄÁË´óÁ¿µÄ×ÊÁÏÖ®ºó£¬ÖÕÓÚÔÚ΢ÈíµÄÒ»¸öʵÀýÖÐÕÒµ½ÁËÒ»ÖÖÁ¼ºÃµÄ·½·¨¡£
Ê×ÏȱàдºÃÒ»Óзµ»ØÖµµÄ´æ´¢¹ý³Ì
create procedure proc_name
@para1 nchar(20), --ÊäÈë²ÎÊý
@ ......
SqlserverÕⶫÎ÷ûÉÙ¸úËû´ò½»µÀ,¸Õѧ¿ª·¢ÓïÑÔʱ¾ÍÒѾ¸úËû½Ó´¥ÁË,²»ÒªËµºÜ¾«Í¨,µ«¾ÍÓï·¨»¹ËãÊÇÊìϤ,µ«ÏÖÔÚ¿ªÊ¼Ð´C#,·¢ÏÖºÜC#¶àÁËÒ»ÖÖSqlServerµÄ²ÎÊý´«È뷽ʽ,ÒÔÍùÎÒÃdz£³£¶ÔÒª´«²ÎµÄSqlÓï¾ä¶¼ÊÇÖ±½Óͨ¹ýÆ´´ÕSqlÓï¾äµÄ·½Ê½À´ÊµÏÖ,µ«ÏÖÔÚC#ΪʲôҪרÃÅ×öÒ»¸öSql²ÎÊýµÄÀàÀ´ÊµÏÖÄØ,¾¹ý²éÕÒ²ÅÖªµÀ,ÕâÑù×öÊÇÓеÀÀíµÄ,Ò»Ê ......
½üÀ´ORM±äµÃÔ½À´Ô½Æձ飬Õⶼ¹éÓÚÒ»Öֺܾß˵·þÁ¦µÄÔÒò£»Ëü¿ÉÒÔʹ¿ª·¢Êý¾Ý¿âÇý¶¯µÄÓ¦ÓóÌÐò±äµÃ¸ü¿ì¡¢¸üÊ¡Á¦¡£µ«ÊÇORM¿ò¼Ü¶¼Óе㓹ÌÖ´¼º¼û”£¬ËûÃÇÆÚÍû¿ª·¢Õß×ñ´ÓÌض¨µÄ¹æÔò£¬µ±¹æÔò±»´òÆƵÄʱºò¾Í·Ç³£ÄÑÒÔʹÓá£×îͨ³£µÄ¹æÔòÖ®Ò»¾ÍÊÇ£¬´æ´¢¹ý³Ì±ØÐë×ÜÊÇ·µ»Øµ¥¶ÀµÄ½á¹û¼¯£¬ÆäÖд ......