LabWindows/CVI

ExcelRpt_ReadData

HRESULT ExcelRpt_ReadData (CAObjHandle worksheetHandle, char cellRange[], enum ExREnum_ExDataType dataType, void *data);

Purpose

Reads the data from the specified cell range.

Parameters

Input
Name Type Description
worksheetHandle CAObjHandle A handle to an Excel Worksheet object.
cellRange char [] A rectangular range of cells.

This value should be a string containing the cell range, such as "A1" or "A1:D5".
dataType enum ExREnum_ExDataType The data type of the array passed in the data parameter. The data type must be one of the following values:

ExRConst_dataDouble = CAVT_DOUBLE
ExRConst_dataString = CAVT_CSTRING
ExRConst_dataCurrency = CAVT_CY
ExRConst_dataDate = CAVT_DATE
Output
Name Type Description
data void * The data array. The array must be at least as big as the value that ExcelRpt_GetNumCellsInRange returns.

In order to read a cell range that is 3 rows by 5 columns you should declare a 2D array as follows:

double dataArray[3][5];

It is possible to use a 1D array to read a cell range that consists of a single row or column. In order to read a cell range that is a single row or column of 10 cells you can declare a 1D array as follows:

double dataArray[10];

The table below specifies the type of array that should be passed based on the selected value of the dataType parameter.

Data TypeArray Type
ExRConst_dataString char *
ExRConst_dataDouble double
ExRConst_dataCurrency CURRENCY
ExRConst_dataDate DATE

When using the String data type you should call the ExcelRpt_FreeStringData function to free the strings allocated by this function.

Return Value

Name Type Description
status HRESULT A value indicating whether an error occurred. Function failure is indicated by a negative error code.

Error codes are defined in CVIversion\include\cviauto.h and <Program Files>\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\winerror.h.

You can use CA_GetAutomationErrorString to get the description of an error code.

Additional Information

Library: Excel Report

Include file: activex\excel\ExcelReport.h

LabWindows/CVI compatibility: LabWindows/CVI 7.0 and later

Log in to get a better experience