![]() |
R1C1 vs A1 addressing
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] = 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 |
R1C1 vs A1 addressing
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 On Sun, 01 Aug 2004 16:53:19 GMT, "netnews.comcast.net" wrote: [i] 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 |
R1C1 vs A1 addressing
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" wrote in message ... 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 On Sun, 01 Aug 2004 16:53:19 GMT, "netnews.comcast.net" wrote: Hi All, I am trying to drive excel from VC++.net and would like to insert data into[i] 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 |
All times are GMT +1. The time now is 09:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com