通过Asp.net在Sql Server表中上载或导入Excel工作表中的多个工作表
我有超过一张工作表excel工作表,我想上传/导入这张excel表到表。
例如:
Excel工作表格式:
表1
Ram | Kumar | 耆那教
Radhe | Mohane | 夏尔马
工作表2
Mohan | Kumar | 古普塔
Chand | Shekhar | 维尔马
我想上传/导入这个Excel中的SQL Server表。
表名:info
名字| 中间名| 姓
链接:
protected void btnUpload_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { string FileName = Path.GetFileName(FileUpload1.PostedFile.FileName); string Extension = Path.GetExtension(FileUpload1.PostedFile.FileName); string FolderPath = ConfigurationManager.AppSettings["FolderPath"]; string FilePath = Server.MapPath(FolderPath + FileName); FileUpload1.SaveAs(FilePath); GetExcelSheets(FilePath, Extension, "Yes"); } }
看看这个链接。 它显示了如何在asp.net中导入Excel,并在SQL Server中加载http://www.codeproject.com/Tips/593181/Load-GridView-from-Excel