ExcelRead

The ExcelRead function reads MS-Excel formatted files.

smMatrix = ExcelRead(ssFileName)
smMatrix = ExcelRead(ssFileName, ssSheetName)
smMatrix = ExcelRead(ssFileName, nSheet)
<smMatrix, smType> = ExcelRead(ssFileName)
<smMatrix, smType> = ExcelRead(ssFileName, ssSheetName)
<smMatrix, smType> = ExcelRead(ssFileName, nSheet)
<rmData, smString, smType> = ExcelRead(ssFileName)
<rmData, smString, smType> = ExcelRead(ssFileName, ssSheetName)
<rmData, smString, smType> = ExcelRead(ssFileName, nSheet)
<rmData, smString, smType> = ExcelRead(ssFileName, nSheet, hStatusWnd)
<rmData, smString, smType> = ExcelRead(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 (smType) element has the value "S" or "B", the corresponding element in rmData has the value 0.0.

smString is a string matrix. If the type matrix (smType) element has the value "S" or "B", the corresponding element in smString has the value "" (empty string).

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

Value

Meaning

""

Number field.

"S"

String field.

"B"

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 smType[1;1] = "".

The number of characters per cell is limited to 2048 characters. Longer strings will be truncated.

Example

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

id-1624412