.net读取excel数据到DataSet中
Dim objExcelFile As Excel.Application
Dim objWorkBook As Excel.Workbook
Dim objSheet As Excel.Worksheet objExcelFile = New Excel.Application
objExcelFile.DisplayAlerts = False
objWorkBook = objExcelFile.Workbooks.Open(filePath)
objSheet = objWorkBook.Sheets() Dim ds As DataSet
Dim da As OleDbDataAdapter
Dim ExcelConn As OleDbConnection
Dim strLength As Integer
Dim ext As String
Dim strCon As String
Dim strSql As String
Dim sInfro As String = ""
Dim path As String = ""
Dim dtDATA As DataTable strLength = filePath.LastIndexOf(".")
ext = filePath.Substring(strLength, filePath.Length - strLength) '扩展名 If ext = ".xlsx" Then
strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + filePath + "';Extended Properties='Excel 12.0;HDR=False;IMEX=1'"
Else
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + filePath + "';Extended Properties='Excel 8.0;HDR=False;IMEX=1'"
End If
ExcelConn = New OleDbConnection(strCon)
ExcelConn.Open()
dtDATA = ExcelConn.GetOleDbSchemaTable(OleDb.OleDbSchemaGuid.Tables, Nothing)
strSql = String.Format("select * from [" & dtDATA.Rows()().ToString & "]")
da = New OleDbDataAdapter(strSql, ExcelConn)
ds = New DataSet()
da.Fill(ds)
ExcelConn.Close()
.net读取excel数据到DataSet中的更多相关文章
- Python用xlrd读取Excel数据到list中再用xlwt把数据写入到新的Excel中
一.先用xlrd读取Excel数据到list列表中(存入列表中的数据如下图所示) import xlrd as xd #导入需要的包 import xlwt data =xd.open_workboo ...
- C#读取excel数据到datatable中
DataTable dtGBPatient = new DataTable(); string strConn;string excelName; //注意:把一个excel文件看做一个数据库,一个s ...
- JAVA反射机制示例,读取excel数据映射到JAVA对象中
import java.beans.PropertyDescriptor; import java.io.File; import java.io.FileInputStream; import ja ...
- Delphi中使用python脚本读取Excel数据
Delphi中使用python脚本读取Excel数据2007-10-18 17:28:22标签:Delphi Excel python原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 . ...
- oledbdataadapter 读取excel数据时,有的单元格内容不能读出
表现:excel中某列中,有的单元格左上角有绿色箭头标志,有的没有,c#编写读取程序,但是只能读取出带绿色箭头的单元格中的内容,其余不带的读取不到内容 原因:excel中单元格因为是文本格式而存储了数 ...
- c#读取Excel数据到Gridview
#region 读取Excel数据到Gridview public void ReadExcel(string sExcelFile, GridView dgBom) { DataTable E ...
- 使用NPOI读取Excel数据到DataTable
如今XML文件的存储格式大行其道,可是也不是适用于全部情况,非常多单位的数据交换还是使用Excel的形式.这就使得我们须要读取Excel内的数据.载入到程序中进行处理.可是如何有效率的读取,如何使程序 ...
- C#读取Excel数据操作大全
苦丁茶 发表于 2014-02-10 12:58:00 | 分类标签: ASP.NET 读取Excel 本文介绍下,用C#读取excel数据的例子,包括读取整个工作薄的数据.读取工作薄选定区域中的数据 ...
- 猜想-未做 利用office组件读取excel数据
---未实际使用过 用SQL-Server访问Office的Access和Excel http://blog.sina.com.cn/s/blog_964237ea0101532x.html 2007 ...
随机推荐
- sys.stdout.flush-倒计时
1. import sys for i in range(100): sys.stdout.write('{}/99\r'.format(i)) sys.stdout.flush() 2. impor ...
- python+requests库,接口自动化
1.requests库的使用 requests是python的一个HTTP客户端库,跟urllib,urllib2类似,那为什么要用requests而不用urllib2呢?官方文档中是这样说明的: “ ...
- C# Excel导入数据
表 表的创建脚本 CREATE TABLE [dbo].[TB_PROJECTS_New1]( , ) NOT NULL, ) NULL, ) NULL, , ) NULL, , ) NULL, , ...
- Java IO、NIO、AIO知识总结
本文主要讲述下自己对IO的理解,对IO的用法和细则可能没有顾虑到. 本文的理解基于以下几篇文章,他们对各自部分都讲的很细,对我理解IO提供了很大帮助. https://www.cnblogs.com/ ...
- linux 下oracle导入dmp文件
2017年08月01日 19:10:49 xuxie13 阅读数:17788 最近要到某公司进行poc演示,整了个新项目,需要我数据库修改项目,这才有了这篇博客. 首先进入linux下oracle ...
- VS2017企业版密钥
Visual Studio 2017(VS2017) 企业版 Enterprise 注册码:NJVYC-BMHX2-G77MM-4XJMR-6Q8QFVisual Studio 2017(VS2017 ...
- pythond的icmp广播报获取局域网主机IP
icmp广播报获取局域网四川特产IP from scapy.all import *import randomimport threading def scan(sip,dip): pkt = Eth ...
- 从 PC 卸载 Office
https://support.office.com/zh-cn/article/%E4%BB%8E-PC-%E5%8D%B8%E8%BD%BD-Office-9dd49b83-264a-477a-8 ...
- R语言读取XML数据
- Winform 时间
using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawi ...