ExcelRead2

The ExcelRead2 function reads MS-Excel formatted files.

smMatrix = ExcelRead2(ssFileName)
smMatrix = ExcelRead2(ssFileName, ssSheetName)
smMatrix = ExcelRead2(ssFileName, nSheet)
<smMatrix, rmType> = ExcelRead2(ssFileName)
<smMatrix, rmType> = ExcelRead2(ssFileName, ssSheetName)
<smMatrix, rmType> = ExcelRead2(ssFileName, nSheet)
<rmData, smString, rmType> = ExcelRead2(ssFileName)
<rmData, smString, rmType> = ExcelRead2(ssFileName, ssSheetName)
<rmData, smString, rmType> = ExcelRead2(ssFileName, nSheet)
<rmData, smString, rmType> = ExcelRead2(ssFileName, nSheet, hStatusWnd)
<rmData, smString, rmType> = ExcelRead2(ssFileName, ssSheetName, hStatusWnd)

Return Value

smMatrix contains the data of an Excel spreadsheet as a string matrix. If an error occurs, smMatrix is a scalar, empty string ("").*rmData* is a real matrix. If the type matrix (rmType) element has the value 2 or 3, the corresponding element in rmData has the value 0.0.

smString is a string matrix. If the type matrix (rmType) element has the value 0 or 3, the corresponding element in smString has the value "" (empty string).

rmType is a real matrix. The elements contain the data types of the corresponding spread sheet cells:

Value Meaning
0 Number field.
2 String field.
3 Blank (empty) field.

Parameters

ssFileName

ssFileName is the name of the Excel file, i.e. "c:\\excel\\test.xls" or c:/excel/test.xls.

ssSheetName

ssSheetName is the sheet name of the Excel 5.0 file. If this parameter is not specified, the first sheet will be read.

nSheet

nSheet is the sheet index of the Excel 5.0 file. If this parameter is not specified, the first sheet will be read.

hStatusWnd

Is the handle of the status bar window. It is used to display processing progress (default is 0). The AppGetStatusBarHandle function returns this handle.

Comment

All output parameters have the same number of rows and columns. A sheet of an Excel 5.0 file can be accessed by the sheet name of the sheet index.

In case of an error, the output parameter has only one element with the value 0.0 or “” (empty string), i.e rmData[1;1] = 0.0, smString[1;1] = "" and rmType][1;1] = 0.

Example

<rmData, smMat, rmType> = ExcelRead2("test1.xls")
if (rmType[1] == 0 && len(rmType) == 1) {
    MessageBox("test1.xls - read error");
}

id-1077008