Writing to an Excel Cell Using VSTO and C#

Euless_Tech
Euless_Tech used Ask the Experts™
on
I am using Visual Studio Tools for Office and am trying to write cells out using a data reader that i populated manually.
Is there a straightforward way to write 6 columns of data starting at a particular row?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
dave4dl,
I had seen than article but I really need one that clears all the affected cells and pastes row by row.
Tommy
Senior Software Engineer
Top Expert 2009
Commented:
You need to use the Value2 property of range:
string[] valuesToAdd = new string[6];
//Setup your values to valuesToAdd
Excel.Range r= Globals.Sheet1.Range("a1","f1");
r.Value2 = valuesToAdd;

The idea is to create a valid range of the target row in the target sheet and  put your data as string array.
Euless_Tech,

What specifically do you not know how to do?  Are you just asking us to write a program for you and have no specific questions?
Miguel OzSenior Software Engineer
Top Expert 2009

Commented:
I provided the answer to this question. He probably forgot to asssign points and close the question

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial