惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
V
Visual Studio Blog
雷峰网
雷峰网
J
Java Code Geeks
博客园 - 三生石上(FineUI控件)
人人都是产品经理
人人都是产品经理
MyScale Blog
MyScale Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
C
Check Point Blog
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
V2EX
D
Docker
IT之家
IT之家
博客园 - 聂微东
腾讯CDC
U
Unit 42
Microsoft Security Blog
Microsoft Security Blog
The Cloudflare Blog

博客园 - Leon0812

Export csv Export Excel Jquery pluign development example XML Mail Template Management Resource file management iframe 中显示内嵌页的局部 - Leon0812 - 博客园 easyslider - Leon0812 - 博客园 缩放页面字体 可编辑DIV - Leon0812 - 博客园 vs快捷键大全(转) SQL文件執行 利用IHttpModule、IHttpHandler做授权类 - Leon0812 - 博客园 C#调用非托管的DLL 无缝滚动 - Leon0812 - 博客园 获取-编译-打包 VS作业一条龙批处理 Reporting Service for SQL 2008匿名访问报表方法 獲取控件位置 - Leon0812 - 博客园 Installscript中修改web.config - Leon0812 - 博客园 publish
Excel Reader
Leon0812 · 2011-08-31 · via 博客园 - Leon0812
       string excelFile = Server.MapPath("~/service/data.xlsx");//string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + excelFile + ";Extended Properties=Excel 8.0;";
string strConn = @"Provider=Microsoft.Ace.OleDb.12.0;Data Source= " + excelFile + ";Extended Properties='Excel 12.0;HDR=No;IMEX=1'";
OleDbDataReader myDataReader
= null;
OleDbConnection myOleDbConnection
= new OleDbConnection(strConn);
OleDbCommand myOleDbCommand
= new OleDbCommand("SELECT * FROM [table1$]", myOleDbConnection);
myOleDbConnection.Open();
myDataReader
= myOleDbCommand.ExecuteReader();
try
{

ModeBiz biz

= new ModeBiz();
Mode model
= new Mode();
string name = string.Empty;
while (myDataReader.Read())
{
model
= new Mode();
name
= myDataReader.GetValue(4).ToString();

biz.Add(model);
}
}

#region Catch
catch (System.Threading.ThreadAbortException ex)
{
ViewBag.ErrMsg
= ex.Message;
}
catch (Exception ex)
{
ViewBag.ErrMsg
= ex.Message;
}
finally
{
myDataReader.Close();
myOleDbConnection.Close();
}
#endregion