Accessing value in a range using Automation in a C# DLL

H

hCoded

Greetings I followed the steps in this blog here to create my C# DLL that
contains my excel 2003 UDFs:

http://blogs.msdn.com/eric_carter/archive/2004/12/01/273127.aspx

The problem I am having is when I pass in a range of cells from excel into
my function which resides inside my Automation DLL I just cannot figure out
how to access the cell values individually. Here is an example of my
functions:

public double SecondValueIs(object Range)
{
int SecondCell= 0;
Excel.Range r = Range as Excel.Range;

//What code do I put here to get the second cell if its a one
row range?
//lets say that I passed in A1:A5?
//
//object value = r.Cells[1,2].value DOES NOT work no VALUE
method ...
//string value = r.Cells[1,2] DOES NOT work .. cant convert COM
object to string ...


return SecondCell;
}

If I look inside r.FormulaLocal for instance I can see a list of my cell
values but I cant convert or otherwise manipulate them. There HAS to be a
way to do so. What am I doing wrong?

Thank you in advance for your time.

~Rob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top