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

ASP.NETÓÚExcelµÄ½»»¥

public DataSet ExcelToDS(string Path)
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Path + ";" + "Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
string strExcel = "";
OleDbDataAdapter myCommand = null;
DataSet ds = null;
strExcel = "select * from [»õÎïÅÉËÍÇé¿ö$]";
myCommand = new OleDbDataAdapter(strExcel, strConn);
ds = new DataSet();
myCommand.Fill(ds, "table1");
conn.Close();
myCommand.Dispose();
return ds;
}
¶ÔÓÚEXCELÖÐµÄ±í¼´sheet([sheet1$])Èç¹û²»Êǹ̶¨µÄ¿ÉÒÔʹÓÃÏÂÃæµÄ·½·¨µÃµ½
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +"Data Source="+ Path +";"+"Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
DataTable schemaTable = objConn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables,null);
string tableName=schemaTable.Rows[0][2].ToString().Trim();
//
public void ExportGridView(GridView gridView1, string filename)
{
string attachment = "attachment; filename=" + filename + ".xls";
HttpResponse Response = HttpContext.Current.Response;
Response.ClearContent();
Response.Charset = "UTF-8";
Response.ContentEncoding = Encoding.Default;
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
// Create a form to contain the grid
HtmlForm frm = new HtmlForm();
gridView1.Parent.Controls.Add(frm);
frm.Attributes["runat"] = "server";

frm.Controls.Add(gridView1);
frm.RenderControl(htw);
//GridView1.RenderControl(htw);
Response.Write(sw.ToString());


Ïà¹ØÎĵµ£º

asp.net³£¼ûÆß´óÄÚÖöÔÏó

Ò»¡¢Response¶ÔÏó
Response¶ÔÏóÊÇHttpResponseÀàµÄÒ»¸öʵÀý¡£¸ÃÀàÖ÷ÒªÊÇ·â×°À´×ÔASP.NET²Ù×÷µÄHTTPÏìÓ¦ÐÅÏ¢¡£
1.Response¶ÔÏóµÄÊôÐÔ
   ¢Ù BufferOutput
   ˵Ã÷£º»ñÈ¡»òÉèÖÃÒ»¸öÖµ£¬¸ÃֵָʾÊÇ·ñ»º³åÊä³ö£¬²¢ÔÚÍê³É´¦ÀíÕû¸öÒ³Ö®ºó½«Æä·¢ËÍ
   ÊôÐÔÖµ£ºÈç¹û»º³åÁ˵½¿Í»§¶ËµÄÊä³ö£¬ ......

asp.net mvc¿ò¼ÜÖÐjsonÐòÁл¯µÄ¿ØÖÆ

ÏÈ¿´ÏÂÃæµÄÒ»¶Î´úÂ룺
 public class UserTest
        {
           public int age { set; get;
}          
¡¡¡¡¡¡¡¡ public string name { set; get; }  & ......

asp.net ·µ»ØÉÏÒ»Ò³µÄʵÏÖ·½·¨

·µ»ØÉÏÒ»Ò³µÄÕâ¸ö¶«¶«ÔÚÎÒÃÇ×öÏîÄ¿µÄʱºòÒ»°ãÊÇÓÃÓÚÌîдÍê±íµ¥ºóÈ·ÈϵÄʱºò£¬ÓжÔÔ­À´ÊäÈëµÄÊý¾Ý½øÐÐÐÞ¸Äʱ
Óõ쬻òÕßÊÇÒòÎªÍøÕ¾ÎªÁË·½±ãä¯ÀÀÕß¶øÓÐÐÄÌí¼ÓµÄÒ»¸ö¶«¶«£¬Ò»°ãÕâÖÖ¹¦ÄܵÄʵÏÖÔÚASP.netÖж¼ÊÇÓÃÒ»¸öbuttonµÄ¿Ø¼þÀ´ÊµÏֵģ¬ÊµÏֵķ½·¨ÓкÜ
¶à£¬½ñÌìÇ¡ºÃÔÚ×öÏîĿʱÅöµ½ÒªÓÃÕâ¸ö¶«¶«£¬ÎҾͰÑÄÜʵÏÖ" · ......

ÈçºÎÔÚASP.NETÖÐʹÓõ¯³ö¶Ô»°¿ò?

1.ASP.NETÖÐʹÓÃAJAXʱÈçºÎµ¯³ö¶Ô»°¿ò
¾ÙÀýÈçÏ£º
ScriptManager .RegisterStartupScript (UpdatePanel1, UpdatePanel1.GetType(), "", "alert('³É¹¦')", true)
ÏÂÃæÕâ¸ö¸´ÔÓЩ
ScriptManager .RegisterStartupScript (UpdatePanel1, UpdatePanel1.GetType(), "", "alert('Ìáʾ£º²úÆ·Ìí¼Ó³É¹¦£¡');if(confirm('ÊÇ·ñ¼ÌÐø ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ