[英]How to get the contents a particular cell using excel data reader in Visual Basic? Using ExcelData Reader
I'm using the following code and I'm trying to understand how to access the content of each cell in the excel document in order to Validate it... but everything that I've found on the internet is in C# I tried to translate it but I'm getting some errors.. this is my code:我正在使用以下代码,并且试图了解如何访问 excel 文档中每个单元格的内容以对其进行验证...但是我在互联网上找到的所有内容都在 C# 我试图翻译它,但我遇到了一些错误。这是我的代码:
Using stream = File.Open(FullUpldPath, FileMode.Open, FileAccess.Read)
Using reader As IExcelDataReader = ExcelReaderFactory.CreateReader(stream)
Dim result As DataSet = reader.AsDataSet(New ExcelDataSetConfiguration() With {
.ConfigureDataTable = Function(__) New
ExcelDataTableConfiguration() With {
.UseHeaderRow = True}})
Dim tables As DataTableCollection = result.Tables
End Using
End Using
Dim file__1 as String = "excelpath"
If file__1.EndsWith(".xlsx") Then
' Reading from a binary Excel file (format; *.xlsx)
Dim stream As FileStream = File.Open(file__1, FileMode.Open, FileAccess.Read)
excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream)
excelReader.IsFirstRowAsColumnNames = True
dtExcelData = excelReader.AsDataSet()
excelReader.Close()
Return dtExcelData
End If
If file__1.EndsWith(".xls") Then
' Reading from a binary Excel file ('97-2003 format; *.xls)
Dim stream As FileStream = File.Open(file__1, FileMode.Open, FileAccess.Read)
excelReader = ExcelReaderFactory.CreateBinaryReader(stream)
dtExcelData = excelReader.AsDataSet()
excelReader.Close()
Return dtExcelData
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.