会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
代码王子
Excel转DataSet的一个例子
public
static
DataSet ExcelToDS(
string
Pathm,
string
TableName)
...
{
DataSet ds
=
new
DataSet();
try
...
{
string
strConn
=
"
Provider=Microsoft.Jet.OLEDB.4.0;
"
+
"
Data Source=
"
+
Path
+
"
;
"
+
"
Extended Properties=Excel 8.0;
"
;
OleDbConnection conn
=
new
OleDbConnection(strConn);
conn.Open();
string
strExcel
=
""
;
OleDbDataAdapter myCommand
=
null
;
strExcel
=
string
.Format(
"
select * from [{0}$]
"
,TableName);
myCommand
=
new
OleDbDataAdapter(strExcel, strConn);
myCommand.Fill(ds, TableName);
}
catch
(Exception ex)
...
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
return
ds;
}
posted on
2007-12-11 23:43
代码王子
阅读(
100
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
导航
博客园
首页
新随笔
联系
订阅
管理
公告