L
Lynn McGuire
Does anyone have experience with sending an array of information to
Excel using OLE Automation and C++ ? I am looking for a way to speed
up the sending of data from our app to Excel. Currently, we send
data to Excel a cell at a time using the following code:
void PutDoubleInTableHorizontal (int row, int column, int count, const double num [])
{
// put the doubles in horizontally
for (int i = 0; i < count; i++)
{
if (uninitializedValue == num )
continue;
std::string cellAddress = GetCellEquivalent (row, column + i);
VARIANT result1;
VariantInit ( & result1);
VARIANT range;
VariantInit ( & range);
range.vt = VT_BSTR;
_bstr_t address = _bstr_t (cellAddress.c_str ());
range.bstrVal = address;
OLEMethod (DISPATCH_PROPERTYGET, & result1, pExcelSheet, L"Range", 1, range);
if (result1.vt == VT_DISPATCH)
{
VARIANT result2;
VariantInit ( & result2);
VARIANT value;
VariantInit ( & value);
value.vt = VT_R8;
value.dblVal = num ;
OLEMethod (DISPATCH_PROPERTYPUT, & result2, result1.pdispVal, L"Value", 1, value);
int res = result2.vt;
result1.pdispVal -> Release ();
}
}
}
I am wondering if sending an array of cells to Excel would be faster ?
Sincerely,
Lynn McGuire
Excel using OLE Automation and C++ ? I am looking for a way to speed
up the sending of data from our app to Excel. Currently, we send
data to Excel a cell at a time using the following code:
void PutDoubleInTableHorizontal (int row, int column, int count, const double num [])
{
// put the doubles in horizontally
for (int i = 0; i < count; i++)
{
if (uninitializedValue == num )
continue;
std::string cellAddress = GetCellEquivalent (row, column + i);
VARIANT result1;
VariantInit ( & result1);
VARIANT range;
VariantInit ( & range);
range.vt = VT_BSTR;
_bstr_t address = _bstr_t (cellAddress.c_str ());
range.bstrVal = address;
OLEMethod (DISPATCH_PROPERTYGET, & result1, pExcelSheet, L"Range", 1, range);
if (result1.vt == VT_DISPATCH)
{
VARIANT result2;
VariantInit ( & result2);
VARIANT value;
VariantInit ( & value);
value.vt = VT_R8;
value.dblVal = num ;
OLEMethod (DISPATCH_PROPERTYPUT, & result2, result1.pdispVal, L"Value", 1, value);
int res = result2.vt;
result1.pdispVal -> Release ();
}
}
}
I am wondering if sending an array of cells to Excel would be faster ?
Sincerely,
Lynn McGuire