zr.
zr.

Reputation: 7798

Excel Automation: read a csv file and update an Excel file

I have an automated test which produces a csv with two columns of data. I have an excel file which I use to gather the results of all the runs in a worksheet.

I want to fully automate the process of updating the Excel file after each test run.

This is probably what I want to do:

1. Read the two columns from the CSV file
2. Paste the two columns in a worksheet in the excel file, in the first 
   empty column to the right of the existing block of columns.
3. Save the Excel file

EDIT:

Now i understand that i can do steps 1-3 using a macro. All that is left for me to figure out is how to launch the macro.

Upvotes: 0

Views: 2810

Answers (2)

DashTechnical
DashTechnical

Reputation: 442

Once you write the macro, it should be in the macro list in Excel for that Excel document. You can bind the macro to a keystroke (like Alt-i, Alt-whatever) so that it runs when your press that key combination.

I've done this on a couple of similar projects where I need to import CSV files from other sources and put the data into an Excel sheet (or sheets)

Upvotes: 0

Chris B. Behrens
Chris B. Behrens

Reputation: 6295

You can read the csv and write to the Excel sheet with a single data provider, the OleDb provider. Here is an article on how to write to Excel, and here is one on how to read csv.

Upvotes: 1

Related Questions