ajReadWorkbook function
Description
The ajReadWorkbook function imports the content of an Excel file into a defined area in the Excel worksheet. It is mainly used for loading data from an Excel file for processing.
Syntax
ajReadWorkbook(source_workbook_path, data_range, [convert_to_text], [run_condition], [run_by_function_point_only])
Argument Name | Argument Type | Description |
---|---|---|
source_workbook_path (required) | String | The path of the file to be read. Remark: The function only supports source workbook in xlsx and xlsm format and it cannot not be the same as current workbook. |
data_range (required) | String | The range of data to read in the source workbook in [sheet]!range_address format. For example, "sheet1!A2:F10". |
convert_to_text (optional) | Boolean | If it equals TRUE, the return result will be converted to string values. If it equals FALSE, the return result will preserve the original data type of each cell. The default value is FALSE. |
run_condition (optional) | Boolean | The function will run when the value is TRUE. Otherwise will not run. The default value is TRUE. |
run_by_function_point_only (optional) | Boolean | If it equals FALSE, the function can be executed through ‘Excel Calculation’ (can be either Automatic or Manual, Calculate Now or Calculate Sheet) or Preview Function Point. If it equals TRUE, the function can be executed with Preview Function Point (AlchemyJ ribbon \ Preview Function Point) only. The default value is TRUE. |
The function will return:
1) Return Value: Contents of specified data range in the selected file
2) Return Type: Multiple values (array formula)
Example
Here is an Excel file to be read by ajReadWorkbook function. Data from A1 to E6 is to be read to the AlchemyJ workbook.
Records in the source Excel are loaded to the selected area.
Click here to download the use case workbooks for further reference.
Error Scenarios
It will return #VALUE! when missing any required parameter or mismatch parameter type. Besides, system will raise error for below scenario(s).
Error Scenario |
---|
Invalid source workbook path, it can be a xlsx file or a xlsm file. |
Invalid data range should be in [sheet name]![range address:] format. For example, sheet1!B2:C3. |
Data range does not exist. |
Target workbook path is same as the path of the current workbook. |