G
Graham Lloyd
I have a C# Automation Add-In that has a simple function like below. It
purpose is to take a 2 strings and a range and query all the cells passed in
the range.
public string helloWorld(string s1,string,s2,object o3)
{
// Cast To Type Range
Excel.Range passedRange=(Excel.Range) o3;
// Loop Through Each Area Passed And Query Value2 Property
foreach(Excel.Range rangeItem in passedRange.Areas)
{
string testValue=rangeItem.value2;
}
}
for example lets say I want to pass 3 items in my range I would enter in my
cell formula
=helloWorld("string1","string2",($A$1,A$2,$A3) )
The code works fine but is really slow. Roughly a second or more on a single
cell. I then copy the formula to a thousand cells it takes 6-8 seconds.
I got this code from the MSDN site and can't find another way to query a
range.
Is there any way to query range with better performance or pass a collection
values to a C# function??
Just as a footnote, the reason I am passing a range object is that my
function needs to take a variable number of arguments and I don't seem to be
able to use ParamArray in C# Automation class. If there is a better way of
passing a variable number of arguments to function then please let me know.
TIA
Graham
purpose is to take a 2 strings and a range and query all the cells passed in
the range.
public string helloWorld(string s1,string,s2,object o3)
{
// Cast To Type Range
Excel.Range passedRange=(Excel.Range) o3;
// Loop Through Each Area Passed And Query Value2 Property
foreach(Excel.Range rangeItem in passedRange.Areas)
{
string testValue=rangeItem.value2;
}
}
for example lets say I want to pass 3 items in my range I would enter in my
cell formula
=helloWorld("string1","string2",($A$1,A$2,$A3) )
The code works fine but is really slow. Roughly a second or more on a single
cell. I then copy the formula to a thousand cells it takes 6-8 seconds.
I got this code from the MSDN site and can't find another way to query a
range.
Is there any way to query range with better performance or pass a collection
values to a C# function??
Just as a footnote, the reason I am passing a range object is that my
function needs to take a variable number of arguments and I don't seem to be
able to use ParamArray in C# Automation class. If there is a better way of
passing a variable number of arguments to function then please let me know.
TIA
Graham