前台代码
<asp:FileUpload runat=server ID=fupFiles Width=px />excel表名<asp:TextBox ID=txtSheet runat=server>Sheet</asp:TextBox>//表名为excel左下角的表名默认为sheetsheet
后台
string excelName = txtSheetText;
string excelPath= fupFilesPostedFileFileName;
string strConn;
strConn = Provider=MicrosoftJetOLEDB;Data Source= + filepath + ;Extended Properties=Excel ;;
OleDbConnection conn = new OleDbConnection(strConn);
OleDbDataAdapter oada = new OleDbDataAdapter ( select * from [ + sheetname + $] strConn );
DataTable dt = new DataTable();
try {
oadaFill(dt);//获得datatable
}
catch( Exception ex) { }