Reading From Excel, Non-Integers

Dec 12, 2011 at 9:41pm
I've gotten my project off the floor (this forum has been extremely helpful) but I've encountered a new problem :\

I've gotten a program written that can read data from Excel spreadsheet cells and display/paste them elsewhere, and as long as they're integers I'm fine. The other information comes in this format 'XX XX XXXU', where Xs are numerical digits and Us are qualifying alphabetical values. I need to be able to store these values so that I can use them elsewhere and I can't seem to do so.

If I try to store them in a string the program will compile and them crash on me when it gets to the point where I try to store the value.

Any Ideas?
Dec 12, 2011 at 10:20pm
Could you perhaps post some code please? how are you trying to 'store' them?
Dec 12, 2011 at 10:38pm
int i=0; <------An integer to store account numbers
string t=""; <------A string to store the turnout where they get the water we sell

...
Excel::_WorksheetPtr pSheet = XL->ActiveSheet;
Excel::RangePtr pRange = pSheet->Cells;
i = pRange->Item[26][3]; <-----Stores a number as an integer fine.
t = pRange->Item[26][2]; <-----This is where is freezes
std::cout << "Account Number is: "<< i << std::endl; //Displays number
std::cout << "Next Account Number is: "<< t << std::endl;

t = pRange->Item[27][3]; is where the foul up is as it tries to store the cell value (Cell B27) as a string.
Last edited on Dec 12, 2011 at 10:46pm
Dec 13, 2011 at 12:39am
closed account (DSLq5Di1)
COM uses a special type of string,
http://msdn.microsoft.com/en-us/library/ms221069%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/zthfhkd6%28VS.80%29.aspx

t = _bstr_t(pRange->Item[26][2]);
Dec 13, 2011 at 6:44pm
Thanks, I figured it was something like that but I couldn't find the solution. You're a life saver.

PROBLEM SOLVED
Topic archived. No new replies allowed.