I have a vector that I need to convert the values to VARIANT so I can pass to Excel. I've looked on the internet and found various things, none have worked (probably because I really don't understnad how to use them correctly). The latest I've tried was using SysAllocString(). Here is what I am doing... I open an input file, read data into a structure and then place into a vector for manipulation so I don't mess up the original data in the structure. I then manipulate the data in the vector a little bit and then spit it out in a .CSV file. That part works. Instead of a .CSV file I would like to move the contents of the vector to cells in an Excel Spreadsheet. I can open Excel and populate cells however I keep getting an error message saying "error C2660: 'Excel::Range::GetItem' : function does not take 0 arguments" when I try to put the contents of the vector into a cell:
This is where I tried using SysAllocString:
VStr = SysAllocString(CompleteCompatVector[i]);
pSheet->Cells->Item[x] = VStr;
That is when I get the following error:
'SysAllocString' : cannot convert parameter 1 from 'std::basic_string<_Elem,_
>' to 'const OLECHAR *'
I cannot find much documentation on this so that is why I am posting here. Is there a better way to handle converting to a VARIANT, am I using an incorrect function and/or is my code just all honked up?