This is a fairly common mistake. In C, when passing an output parameter, you have to pass the
address of a variable that can hold the output data. So in your case, if you're trying to get a string from the function, you would do this:
char *val = NULL;
local_err = ExcelRpt_GetCellValue (workSheetHandle, "A1", ExRConst_dataString, &val);But you should note that this function only gets the value of a single cell. The function description makes that clear. Even though the second parameter is called "cell range," if you read the help, it clarifies that it should be a single cell, or else it will just return the value of the first cell in that range.
You should instead look at the ExcelRpt_ReadData function. You'll use it something like this:
char *AColumnExcel[2000];
local_err = ExcelRpt_ReadData(workSheetHandle, "A1:A2000", ExRConst_dataString, AColumnExcel
);
Note that for both of the functions, the strings returned are allocated by the function, but you are still responsible for freeing each one with a call to CA_FreeMemory:
for (i = 0; i < 2000; ++i)
CA_FreeMemory(AColumnExcel[i]);
Mert A.
National Instruments
Message Edited by Mert A. on
07-31-2008 05:03 PM