使用VB.net编码从excel表中获取数据 [英] get a data from the excel sheet using VB.net coding

查看:205
本文介绍了使用VB.net编码从excel表中获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我找出使用VB.Net编码从excel工作表中获取数据的编码吗.

Can some one help me in finding out the coding for getting data from an excel sheet using VB.Net coding.

推荐答案

您可以直接通过应用程序阅读.Excel或OLEDB,您想要哪个?

这可能有帮助 [
You can read it directly via Application.Excel or by OLEDB, which would you prefer?

This may help[^]


It is very easy to do and a simple googling will answer your question.

Basically you use the interop to open a link to the excel app.
Then point to a cell or range you want to read and then copy (should that be what you want to do).


您需要添加对Microsoft.Office.Interop.Excel的引用.

You need to add a reference to Microsoft.Office.Interop.Excel.

<pre>Dim oXL As Microsoft.Office.Interop.Excel.Application<br />
Dim oBook As Microsoft.Office.Interop.Excel.Workbook<br />
Dim oSheet As Microsoft.Office.Interop.Excel.Worksheet<br />
Dim vValue As Object<br />
<br />
oXL = New Microsoft.Office.Interop.Excel.Application<br />
oBook = oXL.Workbooks.Open("c:\myFile.xls")<br />
oSheet = oBook.Worksheets("Sheet1")<br />
''Here you have cell value, just build a loop to get the data you want<br />
vValue =oSheet.Cells(1, 1).Value <br />
<br />
myTextBox.Text = vValue</pre>


这篇关于使用VB.net编码从excel表中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆