asp.netºÏ²¢excel
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb; //µ¼ÈëÃüÃû¿Õ¼ä
using System.IO;
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;
using System.Data;
using EnterExcel.BLL;
using EnterExcel.Models;
public partial class JoinExcel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) { }
}
private static List<string> listFiles = new List<string>();
List<Pencil> pencilList = new List<Pencil>();
//“½«ExcelÌí¼Óµ½¼¯ºÏÖДʼþ
protected void btnAdd_Click(object sender, EventArgs e)
{
listFiles.Add(this.fuSearchExcel.PostedFile.FileName);
}
//“µ¼ÈëExcelµ½½çÃæ”ʼþ
protected void btnJoinExcel_Click(object sender, EventArgs e)
{
//±éÀú¼¯ºÏ
foreach (string listFile in listFiles)
{
//½«Excel·¾¶Ñ»·¸³¸ø·½·¨
DataTable dt = CreateDataSource(listFile);
foreach (DataRow row in dt.Rows)
{
Pencil pencil = new Pencil();
pencil.Name = row[0].ToString();
pencil.Type = row[1].ToString();
pencil.Number = row[2].ToString();
pencil.Unit = row[3].ToString();
pencilList.Add(pencil);
}
}
this.gvInfo.DataSource = LoadExcelFiles(pencilList);
this.gvInfo.DataBind();
listFiles.Clear();
}
List<Pencil> list = new List<Pencil>();
public List<Pencil> LoadExcelFiles(List<Pencil> pencilList)
{
Pencil p = null;
for (int i = 0; i < pencilList.Count; i++)
Ïà¹ØÎĵµ£º
Ê×ÏȽ¨Á¢¿Ø¼þGridView1£¬×¢ÒâàÞ
Ò³ÃæEnableEventValidation="false"±ØÐëµÄ¡£
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="P ......
ASP.Net ѧϰ֮·µ»ØÉÏÒ»Ò³µÄʵÏÖ·½·¨
[ÈÕÆÚ£º01-20] [×ÖÌ壺´ó ÖРС]
·µ»ØÉÏÒ»Ò³µÄÕâ¸ö¶«¶«ÔÚÎÒÃÇ×öÏîÄ¿µÄʱºòÒ»°ãÊÇÓÃÓÚÌîдÍê±íµ¥ºóÈ·ÈϵÄʱºò£¬ÓжÔÔÀ´ÊäÈëµÄÊý¾Ý½øÐÐÐÞ¸ÄʱÓõģ¬»òÕßÊÇÒòΪÍøվΪÁË·½±ãä¯ÀÀÕ߶øÓÐÐÄÌí¼ÓµÄÒ»¸ö¶«¶«£¬Ò»°ãÕâÖÖ¹¦ÄܵÄʵÏÖÔÚASP.netÖж¼ÊÇÓÃÒ»¸öbuttonµÄ¿Ø¼þÀ´ÊµÏֵģ¬ÊµÏֵķ ......
²¿ÃÅÒª×öÒ»¸öÍøÕ¾£¬ÎÒÒÔÇ°ÓõÄÊÇphp»òasp×öµÄ£¬Õâ»ØÏë¸ÄÓÃasp.net×ö£¬Ö÷Òª»ùÓÚÁ½µã¿¼ÂÇ£¬µÚÒ»£ºÏëͨ¹ýasp.netѧϰc#¼°Æä.net¿ò¼Ü¡£µÚ¶þ£º×Ô¼ºÓÖÏë͵ÀÁ£¬²»Ïë´ÓÍ·¿ªÊ¼×öÍøÕ¾£¬ÓÚÊǾÍÏëÓÿªÔ´µÄnetcmsÀ´¸Ä¸Ä¡£ÓÚÊÇÓÐÁËÎÒµÄϵÁÐÎÄÕ¡£¸ù¾ÝÎÒµÄѧϰ½ø¶ÈÎÒ»áÿÌì¸üУ¬ÇëÅóÓÑÃǹØ×¢¡£ ......
[תÌùÒ»]
ʹÓÃASP.NET MVC¿ò¼Ü£¬´´½¨Ä¬ÈÏÏîÄ¿£¬µÚÒ»Ö±¹Û¸Ð¾õ¾ÍÊǵØÖ·¶¼ÊÇRewrite¹ýµÄ¡£¶ÔÔ´ÂëºÍÅäÖÃÎļþÉÔ¼Ó·ÖÎö²»ÄÑ¿´³ö£¬MVCʹÓÃÁËhttpModulesÀ´À¹½ØµØÖ·ÇëÇ󣬾ßÌåÓõ½ÁËSystem.Web.RoutingÀà¿â£¨MVC2ÖУ¬MVC1ÔõôÓõÄÍü¼ÇÁË¡££©¶øÕⲿ·ÖÀà¿â±»°ü×°ÔÚ.NET Framework3.5 SP1ÖУ¬MVC2ÐèÒªSP1Ö§³ÖÒ²¾ÍÀíËùµ±È»ÁË¡£SP1Ìṩµ ......
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string str = "123456789";
//string str1 = Eval("str").ToString ......