0

I'm trying to read the values from an excel file's stream, unfortunately, after installing ExcelDataReader and ExcelDataReader.DataSet from NuGet packages, I can't create the class IExcelDataReader. It doesn't read the Import neither.

Imports System.IO
Imports ExcelDataReader
Public Class ExcelMng
    Public Function Values_GET(stream As Stream)
        Dim reader As IExcelDataReader
    End Function
End Class

Project's Code

Error found:

'IExcelDataReader' it's not defined.

Things I have tried:

  • Uninstall the packages and installing them again.
  • Changing versions of the packages installed (I lower them down to 3.3).
  • Following tutorials online: https://www.youtube.com/watch?v=pQ1PpcIcHno.
  • Restarting the project.

Relevant information:

  • Platform: .NET Framework 3.5.
  • Things left to do: Uninstall dll packages (I'm not really sure what that means).
3
  • You have to use ExcelReaderFactory.CreateReader() or ExcelReaderFactory.CreateOpenXmlReader(), depending on the Excel file version. ExcelReaderFactory.Create...() returns a configured Reader. To create a Reader, pass a Stream object and a New ExcelReaderConfiguration() object. Don't use the Interface directly. -- Install the NuGet Packages with the Visual Studio NuGet Package Manager (see whether the NuGet version you have supports version 3.3.0 of the package) Commented Dec 16, 2019 at 22:57
  • Get this Package, too: ExcelNumberFormat Commented Dec 16, 2019 at 22:59
  • stackoverflow.com/questions/27634477/… Commented Dec 17, 2019 at 3:42

1 Answer 1

0

I used the following code to run the code, it works well.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim reader As IExcelDataReader
        Dim stream = File.Open("D:\test.xlsx", FileMode.Open, FileAccess.Read)
        reader = ExcelDataReader.ExcelReaderFactory.CreateReader(stream)
        Dim conf = New ExcelDataSetConfiguration With {
            .ConfigureDataTable = Function(__) New ExcelDataTableConfiguration With {
                .UseHeaderRow = True
            }
        }
        Dim dataSet = reader.AsDataSet(conf)
        Dim dataTable = dataSet.Tables(0)
    End Sub

I noted that we need to install .Net Framework 4.5 to run this program.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.