Data Return Excel VB.NET

Asked

Viewed 59 times

0

I have a problem to return the excel data to a Datagridview... I am using the commands below

Dim connectionStringExcel As String = "Driver={0};DriverId=790;
Dbq={1};DefaultDir={2};Extended Properties=""HDR=yes"";"

Dim driverExcel As String = "{Microsoft Excel Driver (*.xls)}"
        conn = New OdbcConnection(String.Format(connectionStringExcel, driverExcel, odb.FileName, Path.GetDirectoryName(odb.FileName)))
cmd = New OdbcCommand("select * from [Plan1$]", conn)
da = New OdbcDataAdapter(cmd)
dt = New DataTable
da.Fill(dt) 

The problem is that when a column has many numerical values it considers as a numerical column and does not return alphanumeric data, I would like to know how to define the data type of the query.

  • I’ve been there, just change the TYPE column in EXCEL.

  • The Column was already in the General Category, I changed the cell formatting to Text but still did not return the data.

  • Give a SAVE AS and change the name.

  • I did the process and still did not solve. Obs. I am using Office 2013.

  • Maybe @Marcelo Bonifazio can help you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.