首页 > Web开发 > 详细

asp.net导入后台代码

时间:2019-02-15 22:18:39      阅读:191      评论:0      收藏:0      [点我收藏+]

  public void Upload(string information){

int Bank = 0;
for (int i = 0; i <Request.Files.Count; i++)
{
var httpfile = Request.Files[i];
string getFileName= httpfile.FileName;
string getfile= getFileName.Substring(getFileName.LastIndexOf("."));
IWorkbook workbook = null;
if (getfile.Equals(".xls"))
{
workbook = new HSSFWorkbook(httpfile.InputStream);
}
if (getfile.Equals(".xlsx"))
{
workbook = new XSSFWorkbook(httpfile.InputStream);
}
ISheet sheet= workbook.GetSheetAt(0);

for (int k = 1; k <7; k++)
{
IRow cells = sheet.GetRow(k);
string sql = string.Format("insert into " + information + "(StudentName,StudentAge) values(");
for (int j = 0; j < cells.LastCellNum; j++)
{
string value = cells.GetCell(j)+"";
sql += string.Format("‘" + value.ToString() + "‘,");
}
sql = sql.Substring(0, sql.Length - 1) + ")";
Bank= DBHelper1.ExecuteNonQuery(sql);
}
}

 

 

}

asp.net导入后台代码

原文:https://www.cnblogs.com/LYYXXXX/p/10386101.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!