在页面完成读取EXCEL
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";
}
}
}
}
}
最新文章
- wordpress /wp-content/plugins/wp-symposium/server/php/UploadHandler.php File Arbitrary Upload Vul
- How to debug windows service
- HDU 5867 Sparse Graph (2016年大连网络赛 I bfs+补图)
- 2.7 编程之美--最大公约数的3种解法[efficient method to solve gcd problem]
- 让apache不区分图片和文件后缀大小写
- URAL 1080 Map Coloring(染色)
- 普通委托到泛型委托到Linq
- nginx重新加载配置
- java加减的二进制实现
- powerDesigner生成数据结构图以及对应sql导出方法
- windows下ngnix+php配置
- 前端 ---jQuery的补充
- wkhtmltopdf 参数介绍
- UVa 11167 Monkeys in the Emei Mountain (最大流)
- 接口文档管理神器RAP2安装和部署
- 利用WebClient实现对Http协议的Post和Get对网站进行模拟登陆和浏览
- TitanX Server安装Caffe
- winform两个窗体之间传值(C#委托事件实现)
- 撩课-Web大前端每天5道面试题-Day11
- MD5随机盐值生成法
热门文章
- Exception in thread ";main"; java.lang.OutOfMemoryError: Java heap space(Java堆空间内存溢出)解决方法
- MpVue开发之框架的搭建
- linux基础【文件夹含义】
- apt-get指令的autoclean,clean,autoremove的区别
- 转载FPGA学习之内嵌乘法器调用
- database - 数据库设计/使用容易忽略的细节
- C#网络编程(接收文件) - Part.5
- 调试VBA程序常用方法
- HashMap源码分析(基于JDK1.6)
- Java 传递可变参数和方法重载