protected void btnUpload_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string sFILENAME = string.Empty;
string sFILE_EXT = string.Empty;
string sFILE_MIME_TYPE = string.Empty;
HttpPostedFile pstIMPORT = fileIMPORT.PostedFile;
if (pstIMPORT != null)
{
if (pstIMPORT.FileName.Length > 0)
{
sFILENAME = Path.GetFileName(pstIMPORT.FileName);
sFILE_EXT = Path.GetExtension(sFILENAME);
sFILE_MIME_TYPE = pstIMPORT.ContentType;
}
if (sFILE_EXT.ToLower() != ".xls")
{
lblError.Text = "The file format is incorrect, please select excel 2003 format file.";
return;
}
ExcelDataReader.ExcelDataReader spreadsheet = new ExcelDataReader.ExcelDataReader(pstIMPORT.InputStream);
if (spreadsheet.WorkbookData.Tables.Count > 0)
{
dt = spreadsheet.WorkbookData.Tables[0];
GridView1.DataSource = dt;
GridView1.DataBind();
if (dt != null && dt.Rows.Count > 0)
{
lblError.Text = "Data read successfully";
}
}
}
}
}

最新文章

  1. wordpress /wp-content/plugins/wp-symposium/server/php/UploadHandler.php File Arbitrary Upload Vul
  2. How to debug windows service
  3. HDU 5867 Sparse Graph (2016年大连网络赛 I bfs+补图)
  4. 2.7 编程之美--最大公约数的3种解法[efficient method to solve gcd problem]
  5. 让apache不区分图片和文件后缀大小写
  6. URAL 1080 Map Coloring(染色)
  7. 普通委托到泛型委托到Linq
  8. nginx重新加载配置
  9. java加减的二进制实现
  10. powerDesigner生成数据结构图以及对应sql导出方法
  11. windows下ngnix+php配置
  12. 前端 ---jQuery的补充
  13. wkhtmltopdf 参数介绍
  14. UVa 11167 Monkeys in the Emei Mountain (最大流)
  15. 接口文档管理神器RAP2安装和部署
  16. 利用WebClient实现对Http协议的Post和Get对网站进行模拟登陆和浏览
  17. TitanX Server安装Caffe
  18. winform两个窗体之间传值(C#委托事件实现)
  19. 撩课-Web大前端每天5道面试题-Day11
  20. MD5随机盐值生成法

热门文章

  1. Exception in thread "main" java.lang.OutOfMemoryError: Java heap space(Java堆空间内存溢出)解决方法
  2. MpVue开发之框架的搭建
  3. linux基础【文件夹含义】
  4. apt-get指令的autoclean,clean,autoremove的区别
  5. 转载FPGA学习之内嵌乘法器调用
  6. database - 数据库设计/使用容易忽略的细节
  7. C#网络编程(接收文件) - Part.5
  8. 调试VBA程序常用方法
  9. HashMap源码分析(基于JDK1.6)
  10. Java 传递可变参数和方法重载