asp.net ʵÏÖexcelµ¼Èëµ½Êý¾Ý¿â
//ExcelÅúÁ¿µ¼Èëµ½Êý¾Ý¿â
protected void btnUpload_Click(object sender, EventArgs e)
{
string IsXls = System.IO.Path.GetExtension(UploadExcel.FileName.ToString().ToLower());
if (IsXls != ".xls")
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script type='text/javascript' language='javascript'>alert('Ö»¿ÉÒÔÑ¡ÔñExcelÎļþ');location.href='EmployeeAddPage.aspx';</script>");
return;//µ±Ñ¡ÔñµÄ²»ÊÇExcelÎļþʱ,·µ»Ø
}
string filePath = UploadExcel.PostedFile.FileName;
string fileName = UploadExcel.FileName;
DataSet ds = ExecleDs (filePath,fileName);
CommonLayer.employeeModel model = new CommonLayer.employeeModel();
DataAcessLayer.employee_infomation addlist = new DataAcessLayer.employee_infomation();
if (ds.Tables[0].Rows.Count > 0)
{
int row = ds.Tables[0].Rows.Count-1;
for (int i = 0; i < ds.Tables[0].Select().Length; i++)
{
&
Ïà¹ØÎĵµ£º
µ¼³öµ½excelµÄ·½·¨ÓжàÖÖ£¬±È½Ï³£¼ûµÄÊÇÖ±½Óµ¼³öµ½EXCEL,»¹ÓоÍÊÇÏȽ«Ò³ÃæµÄÊý¾Ýдµ½´ÅÅÌÎļþ£¬Ö®ºóÖ±½ÓÔÙ´ò¿ªÎļþ£¬ÁíÍ⻹ÓоÍ
ÊǽèÖúµÚÈý·½µÄ¿Ø¼þ¡£
ǰ¶Îʱ¼äдµÄµ¼³öÊý¾Ýµ½excelÔÚexcel2003ÖÐÕý³£¶øÔÚexcel2007ÖÐÊý¾ÝÂÒÂ룬½ñÌìÁ˽⵽ÔÀ´ÊÇResponse.ContentType = "application/ms-excel";µ¼Ö ......
protected void Page_Load(object sender, EventArgs e)
{
/*
sql½Å±¾-´´½¨Ñ§Éú±í
create table student(id int,name varchar(50))
......
string mapho = request["imgpath"];//»ñȡij¸öÒ³Ãæ´«¹ýµÄͼƬÃû³Æ
string str1 = Server.MapPath(mapho);//ÒªÌí¼ÓˮӡµÄͼƬ
string str2 = Server.MapPath("WaterMark.jpg");//Ìí¼ÓµÄÄÚÈÝͼƬ
System.Drawing.Image bmp = System.Drawing.Image.fromFile(str1);
Graphics gs = Graphics. ......
1.¶Á³ö·½Ê½
DataReaderºÍDataSet¶¼¿ÉÒÔʵÏÖ¶ÔÊý¾Ý¿âÊý¾ÝµÄ²éѯ·µ»Ø£¬µ«Ç°ÕßÖ»ÄÜÌṩ¿ìËٵIJéѯ·½Ê½£¬ºóÕß»¹¿ÉÒÔʵÏÖ¶ÔÊý¾ÝµÄÌí¼Ó¡¢Ð޸ġ¢É¾³ý¹¦ÄÜ¡£
£¨1£©DataReader·½Ê½¶ÁÈ¡£º
string sConnString = "server=localhost;User Id=root;password=root;Persist Security Info=True;database=db_user";
MySqlConnection myC ......
×î½üÔÚ×öÒ»¸öÍøÕ¾£¬ÏÔʾÊý¾ÝʱΪÁË·½±ãʹÓÃÁËGridView¡£ËäÈ»GridViewÏÔʾÊý¾ÝµÄ¹¦ÄܺÜǿҲºÜ·½±ã£¬µ«ËüµÄÑùʽȴ²¢²»ÃÀ¹Û¡£ÎªÁËʹGridViewµÄÏÔʾÑùʽÃÀ¹ÛһЩ£¬¾³£ÐèÒªÉèÖñíÍ·µÄ±³¾°£¬ÎÒ×ܽá³öµÄ·½·¨ÈçÏ£º
·½·¨Ò»£º
ÔÚGridViewµÄOnRowDataBoundʼþÖÐÉèÖñ³¾°£¬´úÂëÈçÏ£º
protected void GridView1_RowDataBound(ob ......