R1C1 vs A1 addressing

  • Thread starter netnews.comcast.net
  • Start date
N

netnews.comcast.net

Hi All,

I am trying to drive excel from VC++.net and would like to insert data into
a range addressed using the R1C1 style. Here is how I know it works (from
the SDK samples):

Range* range2 = worksheet->get_Range(S"A1", S"E1");
int array2 __gc[] = new int __gc[5];
for (int i=0; i < array2->GetLength(0); i++)
{
array2 = i+1;
}
range2->Value2 = array2;

My QUESTION is: how can I change the addressing from "A1" / "E1" to R1C1 /
R1C5. If I just replace the strings it fails.

Hope someone can HEEEELP!!!

Fizikus
 
M

Myrna Larson

I don't know C++, but you should look at the specs for the Get_Range
function/method. If it requires A1 syntax, you can't change that. So your
problem becomes how to translate an address like R1C5 into E1.

Here's a VBA function that translates a column number to the appropriate
letter. You'll have to translate it to C++.

Function ColumnLetter(Col As Integer) As String
Dim C As Integer
C = Col - 1
If C < 26 Then
ColumnLetter = Chr$(C + 65)
Else
ColumnLetter = Chr$(C \ 26 + 64) + Chr$(C Mod 26 + 65)
End If
End Function
 
N

netnews.comcast.net

Thanks for the advice -- I guess I have to use some workaround. I wanted to
make sure that those who know how to do it would follow the same route...

Regards, Fizikus

Myrna Larson said:
I don't know C++, but you should look at the specs for the Get_Range
function/method. If it requires A1 syntax, you can't change that. So your
problem becomes how to translate an address like R1C5 into E1.

Here's a VBA function that translates a column number to the appropriate
letter. You'll have to translate it to C++.

Function ColumnLetter(Col As Integer) As String
Dim C As Integer
C = Col - 1
If C < 26 Then
ColumnLetter = Chr$(C + 65)
Else
ColumnLetter = Chr$(C \ 26 + 64) + Chr$(C Mod 26 + 65)
End If
End Function


Hi All,

I am trying to drive excel from VC++.net and would like to insert data into
a range addressed using the R1C1 style. Here is how I know it works (from
the SDK samples):

Range* range2 = worksheet->get_Range(S"A1", S"E1");
int array2 __gc[] = new int __gc[5];
for (int i=0; i < array2->GetLength(0); i++)
{
array2 = i+1;
}
range2->Value2 = array2;

My QUESTION is: how can I change the addressing from "A1" / "E1" to R1C1 /
R1C5. If I just replace the strings it fails.

Hope someone can HEEEELP!!!

Fizikus

 
Top