Working with Excel

Class library usage, coding and language questions.
jainaakash
Posts: 48
Joined: Thu Jun 10, 2010 12:06 pm

Working with Excel

Post by jainaakash » Fri Jun 25, 2010 1:28 pm

Hi Team,

Could you please provide me a sample code for reading from and writing to excel using VB.NET.
I would like to take input from a spreadsheet into a variable and then use it in the script.

Thanks for your help.

Regards,
Aakash

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Working with Excel

Post by Support Team » Fri Jun 25, 2010 1:32 pm

Hi,

Please read the following blog
http://www.ranorex.com/blog/data-driven ... with-excel

Regards,
Peter
Ranorex Support Team

jainaakash
Posts: 48
Joined: Thu Jun 10, 2010 12:06 pm

Re: Working with Excel

Post by jainaakash » Fri Jun 25, 2010 2:31 pm

Hi Peter,

Thanks for your quick response. I went through the blog link you mentioned but was not able to understand & get it working. Could you please provide a bit more detailed explaination with steps to be followed and get me a sample code in VB.NET.

To be simple, I have created one spreadsheet with two columns, 'FirstName' & 'LastName'. Now, I want to get the values for both the columns and display in a pop-up msgbox. I am not sure how to Create an Excel Application Object and Open the File to read the values from it.

Apologies for being annoying.

Thanks and Regards,
Aakash

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: Working with Excel

Post by sdaly » Mon Jun 28, 2010 12:47 pm

I use this as below....

Add the CSVConnector.vb file to your project

Then use like this -

Dim testData as New CSVConnector("AddEditDeleteTestData.csv")
For Each row As DataRow In testData.Rows

msgbox(row("FirstName").ToString())
msgbox(row("LastName").ToString())
Next
testData = Nothing

Hope this helps!