zoukankan
html css js c++ java
asp.net从excel导入数据
注意,导入的文件必须在服务器上,因此必须先上传文件到服务器然后再导入。
///
<
summary
>
///
导入数据到数据集中
///
</
summary
>
///
<
param name
=
"Path"
></
param
>
///
<
param name
=
"TableName"
></
param
>
///
<
param name
=
"tablename2"
>
如果这个有就以他为表名,没有的话就以TableName
</
param
>
///
<
returns
></
returns
>
public
DataTable InputExcel(string Path,string TableName,string tablename2)
{
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
;
if
(tablename2.Length
>
0
&&
!tablename2.Equals(string.Empty))
TableName
=
tablename2;
strExcel
=
"
select
*
from
[
" + TableName + "$
]
";
myCommand
=
new OleDbDataAdapter(strExcel, strConn);
DataTable dt
=
new DataTable();
myCommand.Fill(dt);
conn.
Close
();
return
dt;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
查看全文
相关阅读:
ExtJs 4.0 ExtJs2.2 JavaScript
C++中关于classview、resourceview、fileview
BIN OBJ 区别
数据编码
多线程
REST
SQL Server 2005安装
临时
数据存储
灰度直方图
原文地址:https://www.cnblogs.com/ringwang/p/1238116.html
最新文章
文件流之字节缓冲流(BufferedInputStream BufferedOutputStream)
Jenkins中集成Gcov代码覆盖率报告
CMake如何执行shell命令
LCOV 如何过滤iostream等系统函数的覆盖率信息
cmake 学习笔记(一)
显示ubuntu 10.4右上角网络图标
ubuntu 10.4非法关机后上不了网
安装交叉编译器arm-linux-gcc
linux内核驱动——从helloworld开始
ubuntu删除该目录下所有*.svn
热门文章
一个查询ip地址的mysql数据库--ip2nation
casperjs,phantomjs,slimerjs and spooky
phpDocumentor
语义化版本
Promise & Deferred Objects in JavaScript Pt.2: in Practice
Promise & Deferred objects in JavaScript Pt.1: Theory and Semantics.
html5 js 游戏的一篇博客 貌似不错
Fix for: Permission denied to access property 'toString'
nginx alias
laravel 资料
Copyright © 2011-2022 走看看