|
|
|
|
|
- Cell content: taking the empty rows and columns into account
- Handling errors
- Type of data retrieved
xlsData (Function) In french: xlsDonnée Retrieves the content of a cell found in an XLS file. The result depends on the opening mode of XLS file: - In multi-sheet mode, the data retrieved is found on the worksheet selected by xlsCurrentWorksheet.
- In compatible mode, the data retrieved is always found on the first worksheet of the workbook.
Note: The content of a cell in an XLS file can only be retrieved if: - The XLS file exists.
- The XLS file is opened.
New in version 2025
ResData is string
XLSFileID is int
XLSFileID = xlsOpen("C:\MyDirectory\File.XLS")
IF XLSFileID <> -1 THEN
ResData = xlsData(XLSFileID, 3, 4)
...
END
cMyXLSFile is xlsDocument
cMyXLSFile = xlsOpen(sMyFile, xlsWrite)
IF ErrorOccurred = False THEN
Azz is int = xlsCurrentWorksheet(cMyXLSFile)
Info("Current worksheet in the Excel file: " + Azz)
IF xlsCurrentWorksheet(cMyXLSFile, 2) = True THEN
Info("The current worksheet was modified.")
Info(xlsData(cMyXLSFile, 11, 2))
ELSE
Error("The selected file does not include a second worksheet!")
END
ELSE
Error(ErrorInfo(errFullDetails))
END
xlsClose(cMyXLSFile)
Syntax
Syntax that uses the xlsDocument type Hide the details
<Result> = xlsData(<XLS document> , <Row number> , <Column number> [, <Empty rows and columns>])
<Result>: Character string - Content of specified cell.
- If the cell content corresponds to an empty string (""), this may correspond to an error. In this case, the ErrorOccurred variable is set to True and xlsMsgError returns the details of the error.
<XLS document>: xlsDocument variable Name of the variable of type xlsDocument to be used. <Row number>: Integer Row number of the cell to be read. <Column number>: Integer Number of the column for the cell to read. <Empty rows and columns>: Optional boolean Defines how the empty rows and columns will be taken into account:
| | False | The empty rows and columns are taken into account. | True (by default) | The empty rows and columns are ignored. |
Syntax kept for backward compatibility with version 12 Hide the details
<Result> = xlsData(<XLS file identifier> , <Row number> , <Column number> [, <Empty rows and columns>])
<Result>: Character string - Content of specified cell.
- If the cell content corresponds to an empty string (""), this may correspond to an error. In this case, the ErrorOccurred variable is set to True and xlsMsgError returns the details of the error.
Note: If the Excel file has been opened in compatible mode, the cell content cannot exceed 255 characters.
<XLS file identifier>: Integer Identifier of the XLS file to handle, returned by xlsOpen. <Row number>: Integer Row number of the cell to be read. <Column number>: Integer Number of the column for the cell to read. <Empty rows and columns>: Optional boolean Defines how the empty rows and columns will be taken into account:
| | False | The empty rows and columns are taken into account. | True (by default) | The empty rows and columns are ignored. |
Remarks Cell content: taking the empty rows and columns into account The empty rows and columns can be taken into account or not. For example:
xlsData(XLSFileID, 2, 3, True)
xlsData(XLSFileID, 2, 3, False)
In this example, the column C (that is entirely empty) can be taken into account or not. Handling errors If an error occurs, xlsData returns an empty string (""). To get more details on the error, use xlsMsgError or ErrorInfo with the errMessage constant. xlsData throws an error in the following cases: - The specified row and/or column is empty.
- The specified XLS file does not exist.
- The specified XLS file is not opened.
Type of data retrieved xlsData returns a string, regardless of the cell format defined in Excel. Note: The "High-precision numeric" type is not supported by Excel. The Numeric value retrieved will be truncated. | | If the content of the specified cell has the following type: | The result is converted into: | Numeric | String | Date | String in DD/MM/YYYY format | Time | String in HH:MM:SS format |
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|