09-22-2006 12:26 PM
09-25-2006 02:01 PM
09-25-2006 03:22 PM
If I follow your question, perhaps the following code could be re-packaged into a function that does the job for you:
char cell[8];
char col; // this is used as number
int row;
col = 'B'; // single quotes - this is not a string
row = 2;
Fmt(cell, "%s<%c%d", col, row);
ExcelRpt_SetCellValue (ws_handle, cell, ExRConst_dataString, string);
Note that if you ever have more than 26 columns, this won't work -- the col variable won't work beyond Z, as it can't be 'AA'. You might want to use the "RnCm" notation (e.g. R2C2 instead of B2). However, I'm unsure if this format is supported by the SetCellValue function; a quick test of that notation gave me an error. (If anyone can confirm this question, please post!)
The nice thing about this char version of col is that you can easily do math with it. You can increment it, e.g. col = col +2, or col++ (Watch your types, and check its within range, though!) You probably will need to supply two integer arguments (for row and column) and add a zero-based integer value cast to char for the column number to the char value 'A'.
Hope this helps,
--Ian
09-25-2006 06:32 PM
09-26-2006 04:01 PM
Yes, as a standalone statement,
col++;
is the same as
col = col+1;
or for that matter
col += 1;
The increment operator (++) and decrement operator (--) can also be embedded in a longer statement. See your favorite C reference book, or this link: http://www.lysator.liu.se/c/bwk-tutor.html#increment
In general you will not need that operator. Just do something like this:
char col;
int column_num;
column_num = 8; // whatever you like; in this case H
col = 'A' + column_num - 1; // note automatic type casting is going on here, since we are mixing int and char in our math
if (col < 'A' || col > 'Z') Breakpoint(); // check the range somehow - this works during debugging only
Good luck.
--Ian
10-27-2006 11:34 AM
for some reason when I try to increment my col it doesn't change the value. I have the following in my code currently
Fmt(cell, "%s1", colcounter);
ExcelRpt_SetCellValue(worksheetHandle, cell, Enum_datatypeString, data);
colcounter = colcounter + 1;
off++;
off here is my incrementer, Everytime I press the button that this is associated with off increments and a new value is put into data to be written across the top row of the spreadsheet. The idea is putting headers across, but this is just practice for now to prove I can do it. But when I set my colcounter as a watch variable the value of colcounter always remains 65, which is A. my declarations are
char colcounter = 'A'
int off = 1
I can't figure out why the value of colcounter never changes. Thanks
Niet.
10-27-2006 01:14 PM