The ajWriteWorkbook function exports data from a range of cells in an Excel worksheet to another Excel file.
ajWriteWorkbook(data_range, target_workbook_path, start_address, [convert_to_text], [run_condition], [run_by_function_point_only])
|Specify the range of cells to be written into the file. The range of cells can span across multiple rows and columns. It must be a range in the current workbook.|
|Specify the path of the Excel file to be written. |
The function will create an Excel file automatically if the specified file path does not exist. Ensure that the current user has privilege to add/update files in the specified path.
Remark: The function only supports the target workbook in xlsx and xlsm format and it cannot not be the same as the current workbook.
|Specify the top-left cell of the range to write in the target workbook in the [sheet]!cell_address format. |
For example, "sheet1!A2".
The function will check the range size in data_range to determine the actual range in the target workbook.
|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.
If you do not specify anything, the default value will always be FALSE.
The function will run when the value is TRUE. Otherwise will not run.If you do not specify anything, the default value will always be TRUE.
|If it equals FALSE, the function can be executed through ‘Excel Calculation’ (can be either Automatic or Manual, Calculate Now or Calculate Sheet) or Run Function Point. |
If it equals TRUE, the function can be executed with Run Function Point (AlchemyJ toolbar / Run Function Point) only.If you do not specify anything, the default value will always be TRUE.
The function will return:
1) Content type
TRUE: Data has been written to the target workbook successfully.
#VALUE!: Data cannot be written to the target workbook.
2) Method: Within a cell
This example will export data from cell B1 to cell F6 to a separate Excel workbook.
A new excel file WriteWB.xlsx is created in the specified path. In the below screenshot, you can see the data is copied from the original Excel to the target Excel. Please note that the format in the AlchemyJ Workbook will not be exported to the new Workbook.