Reading Variant Array from Excel

Reading Variant Array from Excel

Post by Jose » Mon, 20 Nov 2006 01:30:10


Hi!

I'm writing an Excel addin which reads and writes ranges of cells. The
following code works fine however it produces huge memory leaks (the
example produces 15MB memory leak). Every time the function
r->get_Value(); is called and returns Variant array instead of just
single Variant value the memory occupied by the array is not freed.
This strange behaviour does not occur when writing values to Excel
(r->set_Value();).

#include <vcl\office_2k.h>
#include <vcl\excel_2k_srvr.h>

TExcelApplication *excelApp;
Variant arrV;

ExcelWorkbookPtr workbook = (ExcelWorkbookPtr)
excelApp->get_ActiveWorkbook();
SheetsPtr worksheets = workbook->get_Worksheets();
ExcelWorksheetPtr problemSheet = (ExcelWorksheetPtr)
worksheets->get_Item((TVariant)"Problem");

RangePtr r;
r = problemSheet->get_Range((TVariant)"A1:CA20000", EmptyParam);

arrV = r->get_Value();
arrV = Unassigned;

r.Release();
problemSheet.Release();
worksheets.Release();
workbook.Release();

I'm using Borland C++ Builder 6 update 4. Anybody has some idea what
might be wrong with this code? Thanks for any help!
 
 
 

1. Q re returning a variant array of variants

2. 2D array of variant broken wire to Database Variant to Data

Database connectivity toolkit functions -
I am trying to connect output from DB Tools Select Data to the
Database Variant to Data functions. I get an error of broken wire:
These cannot be wired together because their data types (numeric,
string, array, cluster, etc.) do not match. Show the Context Help
window to see what data type is required.
The type of the source is 2-D array of Variant.
The type of the sink is 2-D array of Variant.

What is going on here? I suspect that the arrays themselves have
different shapes, but I have no idea how to fix that. Or, variant data
doesn't matach variant data no matter what.

3. OLE variant array of variants

4. How to read a string from a variant array ?

5. Reading Array of UINT16 in to a VARIANT datatype

6. Matlab array into vbscript variant array (no double!)

7. Passing an array of array of VARIANTS

8. DELPHI - VB array of array of variant

9. Passing Object Array back to Variant array.

10. Convert Matlab array to COM VARIANT array?

11. How to cast a variant array to be a long array?

12. Can't Assign Array to Variant in Array

13. DELPHI - VB array of array of variant

14. array of array of variants