先写个帮助类FileUpload_Help 然后添加一个静态方法: private static bool UpLoadFile(System.Web.UI.HtmlControls.HtmlInputFileinputFile, string fileName) ... {//文件上传的路径最好是配置在Web.Config里,这就写死了stringUploldFolderName=Thread.GetDomain().BaseDirectory+@"UploadFilsExcels";try...{if(Directory.Exists(UploldFolderName)==false)...{Directory.CreateDirectory(UploldFolderName);}...{inputFile.PostedFile.SaveAs(UploldFolderName+fileName);returntrue;}}catch...{returnfalse;}} 再添加获取Excel内容的静态方法: private static DataTableGetTheExcelContent( string fileName) ... {stringTheFileName=@"UploadFilsExcels"+fileName;stringconnString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource='"+TheFileName+"';ExtendedProperties=Excel8.0";OleDbConnectionconnxls=null;DataSetds=newDataSet();try...{connxls=newOleDbConnection(connString);OleDbDataAdapterxlsAd=newOleDbDataAdapter("select*from[Sheet1$]",connxls);xlsAd.Fill(ds);}catch...{}finally...{if(connxls.State!=ConnectionState.Closed)...{connxls.Close();}}returnds.Tables[0];} 现在两个都是私有方法,得对外暴露一个公开的方法: public static DataTableUploadFileAndGetTheContent(System.Web.UI.HtmlControls.HtmlInputFileinputFile, string fileName) ... {if(UpLoadFile(inputFile,fileName))...{returnGetTheExcelContent(fileName);}else...{returnnull;}} 异常处理都没写,具体使用的时候还要添更强的逻辑 不过雏形差不多就这样了