vb读取excel数据的教程
时间:2022-07-04 12:26:05
在Excle中录入好数据以后,可能会需要用VB进行读取Excle数据,具体该如何读取数据呢?下面是小编带来的关于vb读取excel数据的教程,希望阅读过后对你有所启发!
vb读取excel数据的教程:
Private Sub Form_Load()
Text1.Text = App.Path & "\123.xls"
Text2.Text = App.Path & "\123.mdb"
Text3.Text = "sheet1"
Text4.Text = "sheet1"
Data1.DatabaseName = App.Path & "\123.mdb"
End Sub
Private Sub Command1_Click()
Dim db As Database
Dim sheet As String, excelpath As String, AccessPath As String, AccessTable As String
AccessPath = Text2.Text '数据库路径
excelpath = Text1.Text '电子表格路经
AccessTable = Text4.Text '数据库内表格
sheet = Text3.Text '电子表格内工作表
Set db = OpenDatabase(excelpath, True, False, "Excel 5.0") '打开电子表格文件
SQL = ("Select * into [;database=" & AccessPath & "]." & AccessTable & " FROM [" & sheet & "$]")
db.Execute (SQL) '将电子表格导入数据库
Data1.RecordSource = "sheet1"
Data1.Refresh
DBGrid1.Refresh '显示电子表格导入到数据库的数据
End Sub
上面的是把EXCEL读取到数据库中,你做点修改就行了.一个Data控件.
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Word2013文档英文字母更改大小写的方法
![](https://img.aspxhome.com/file/2023/4/20754_0s.jpg)
Excel隔行求和,用快捷键轻松搞定
![](https://img.aspxhome.com/file/2023/9/22539_0s.jpg)
word文本怎么对齐? word文本巧用制表位对齐的方法
![](https://img.aspxhome.com/file/2023/3/26423_0s.jpg)
Excel 2019怎么制作组合图?Excel2019制作组合图方法
取消Excel网格线
Word 2007增强的“比较”文档功能介绍
![](https://img.aspxhome.com/file/2023/6/30376_0s.jpg)
在word文档中如何制作表格呢?
![](https://img.aspxhome.com/file/2023/5/24035_0s.jpg)
excel怎么分列数据?excel分列功能介绍
![](https://img.aspxhome.com/file/2023/7/40867_0s.png)
excel表格统计同一类型数量的方法
word2010中怎么添加电子印章?
![](https://img.aspxhome.com/file/2023/0/27070_0s.jpg)
如何在Word 2016中调整图像大小或裁剪图像?
![](https://img.aspxhome.com/file/2023/2/23542_0s.jpg)
excel如何设置页码
Win10怎么关闭电脑的实时防护功能?Win10关闭实时防护方法教学
![](https://img.aspxhome.com/file/2023/8/49568_0s.jpg)
Win10怎么永久关闭自动更新?Win10如何永久关闭自动更新
![](https://img.aspxhome.com/file/2023/8/50548_0s.png)
WPS表格附件怎么添加
![](https://img.aspxhome.com/file/2023/3/a164113_0s.jpg)
excel表格0001怎么打
FineReport怎么插入图片并设置展示?
![](https://img.aspxhome.com/file/2023/4/15144_0s.jpg)
win10系统玩魔兽如何设置全屏
![](https://img.aspxhome.com/file/2023/6/46816_0s.png)
Excel中怎么添加漂亮的横条纹?
![](https://img.aspxhome.com/file/2023/9/a141779_0s.jpg)
Win10任务栏图标显示异常怎么办?Win10任务栏图标异常解决方法
![](https://img.aspxhome.com/file/2023/8/51678_0s.png)