Home > Software engineering >  How to extract the contents of COleVariant inside? There are many lines of excel data cell content
How to extract the contents of COleVariant inside? There are many lines of excel data cell content

Time:11-09

How to extract the contents of COleVariant inside? There are many data line excel cell contents
When the debug has seen read content, how to extract?
Following can only take to a content, how to extract the content of the other?
Cstrings strTmp [100].
StrTmp [0]=ContentArray. BstrVal;


- ContentArray {????? } COleVariant
- tagVARIANT safearray of VARIANT=(1, 5) (BSTR=0 x01440f34 ReturnValue, BSTR=0 x01440f6c UserInput, BSTR=0 x0144822c "ErrorMessage", BSTR=0 x01448264 ReturnValue, BSTR=0 x0144829c "evm entry") tagVARIANT
N 8204 unsigned short
- safearray zero x01440e90 safearray of VARIANT=(1, 5) (BSTR=0 x01440f34 ReturnValue, BSTR=0 x01440f6c UserInput, BSTR=0 x0144822c "ErrorMessage", BSTR=0 x01448264 ReturnValue, BSTR=0 x0144829c "evm entry") tagSAFEARRAY *
+ [1, 1] BSTR=0 x01440f34 "ReturnValue tagVARIANT
+ (2, 1] BSTR=0 x01440f6c "UserInput tagVARIANT
+ (3, 1] BSTR=0 x0144822c "ErrorMessage" tagVARIANT
+ (4, 1) BSTR=0 x01448264 "ReturnValue tagVARIANT
+ (5, 1] BSTR=0 x0144829c "evm entry" tagVARIANT

CodePudding user response:

Reference COleSafeArray
 
//sa is of type COleSafeArray with 2 dimensions

//Determine upper bounds for both dimensions
Long lNumRows;
Long lNumCols;
Sa. GetUBound (1, & amp; LNumRows);
Sa. GetUBound (2, & amp; LNumCols);

//Display the elements in the SAFEARRAY.
Long index [2];
The VARIANT val.

//Determine the lower bounds for both dimensions
Long lowRow lowCol;
Sa. GetLBound (1, & amp; LowRow);
Sa. GetLBound (2, & amp; LowCol);

For (long r=lowRow; R & lt;=lNumRows; R++)
{
For (long c=lowCol; C & lt;=lNumCols; C + +)
{
The index [0]=r;
The index [1]=c;

//retrieve the each element of the safearray
Sa. GetElement (index, & amp; Val);

The switch (val. Vt)
{
Case VT_R8:
TRACE (_T (" % 1.2 f \ n "), val. DblVal);
break;

Case VT_BSTR:
TRACE (_T (" % s \ n "), (cstrings) val. BstrVal);
break;

//other cases omitted

Case VT_EMPTY:
TRACE (_T (" & lt; Empty> \ n "));
break;
}
}
}



CodePudding user response:

Thank you, I mean have read many column content, but how to put it out from the contentarray?

CodePudding user response:

COleSafeArray has a constructor to receive COleVariant parameter of type...
  • Related