Read Excel sheet by using Vb.net

Hi Team,
I want to read the Excel data and get the Data table by using vb.net code.

I have tried with excel and workbook activities.workbook Readrange is not working as the excel sheet contains .xls extension.and excel application scope is working but sometimes getting stuck .so wanted to check by using VB.net.

Please send me the code details or any small example by using invoke code activity.

Regards,
Priya

Hey @Priyambada_Panda

The .XLS format doesn’t matter.

Kindly show us the error please…

Thanks
#nK

Please find the screenshot and let me know what needs to be done

Hello @Priyambada_Panda

Please refer to the below post.

I have already gone through this post.but it does not help me.i need to read the data from excel and get the data table.

Hi @Priyambada_Panda,

I’m sharing links that I think will help. I hope that will be useful. Also have you tried upgrading or downgrading the Excel activity pack and running it?

Regards,
MY

1 Like

Sir,
I have tried with Excel,the problem is sometimes the Robot is getting stuck at the Excel Application scope activity.The reason i found from the forum is sometimes excel is searching for license which maybcsuse the Robot stuck .so to avoid this i ttied with Wotkbook read range.that is also creating problem.

Got it, in that case you can also try to read it with VB or python script.
Did the above link work for you for VB? @Rahul_Unnikrishnan

I have tried with vb.net.but facing the above issue.trying to figure it out.please suggest me what needs to be done.

Could you please paste the code here !

Also you can add try catch inside the vb editor to see the exact error !

Thanks
#nK

Dim myConnection As system.data.OleDb.OleDbConnection
Dim dtset As system.data.DataSet
Dim MyCommand As system.data.OleDb.OleDbDataAdapter
myConnection=New system.Data.OleDb.OleDbConnection(“Provider=Microsoft.ACE.OLEDB.6.0;Data Source=‘D:\Employee.xls’;Extended Properties=‘Excel 4.0;HDR=Yes;IMEX=1;’”)
MyCommand=New System.Data.OleDb.OleDbDataAdapter(“select * from [Sheet1]”,myConnection)
dtset=New System.Data.DataSet
MyCommand.Fill(dtset)

its failing in MyCommand.Fill(dtset) this line

Hi @Priyambada_Panda ,

Could you maybe also provide us the Error Message that was received for that line ?

Hi @Priyambada_Panda

First you have to convert the excel file xls to xlsx…

The issue will be fixed… your are using download from the website… code issue on download the file…

Thanks
Shyam

.xlsx is not supporting in my machine. After converting its showing error “File corrupted”

can you share xmal file

@Priyambada_Panda Check any input arguments need to be pass to that invoke code

Yes.Input argument is “Path”.its already provided

The issue has been Solved.

As Read range workbook was not working for .xls file ,i have saved(Save as) the file again in to .xlsx by using invoke code activity.and Used read range workbook activity yo get the data table.And now its working as expected.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.