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

推荐订阅源

C
Check Point Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
GbyAI
GbyAI
WordPress大学
WordPress大学
月光博客
月光博客
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Google DeepMind News
Google DeepMind News
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
博客园 - 司徒正美
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
Blog — PlanetScale
Blog — PlanetScale
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
L
LangChain Blog
腾讯CDC
T
The Blog of Author Tim Ferriss
量子位

博客园 - pysharp

openstack horizon api step by step understanding horizon's template path what can PsTools\psexec do! - pysharp What's New in Python3.0 - pysharp [转]利用adsutil.vbs脚本创建自定义web站点 我的2008. sql基础篇,不断更新中...... TypeConvert Demo javascript 调试器v1.0.0.0 Dundas Chart Demo For New User - pysharp c#面向对象中的继承初步认识 .net 集合类初步认识 c# 目录操作类 c# 文件操作类 - pysharp - 博客园 关于urlrewrite的小DEMO - pysharp - 博客园 c# 动态编译方法 asp.net 下载和在线预览Excel的方法 排序算法 c#实现 简单使用nHibernate,新手练习用。
c# 读取Excel到datable
pysharp · 2008-01-24 · via 博客园 - pysharp

直接代码:
using System.Data.OleDb;

string fileName = myFile.FileName;
string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(fileName) + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1'";
                OleDbConnection conn = new OleDbConnection(connStr);
                OleDbCommand comm = new OleDbCommand();
                comm.Connection = conn;
                comm.CommandText = "select * from [" + excelName + "$]";
                OleDbDataAdapter ada = new OleDbDataAdapter();
                DataSet ds = new DataSet();
                ada.SelectCommand = comm;
                ada.Fill(ds, excelName);
                DataTable dt = ds.Tables[excelName];

HDR属性决定读不读列名。
 “IMEX=1;”通知驱动程序始终将“互混”数据列作为文本读取。