WriteExcelFile Activity
Purpose: This activity writes data to an Excel file. The data is provided as a JSON string and is written to the specified Excel file path. This is useful for exporting workflow data to Excel format for reporting, analysis, or further processing in spreadsheet applications.
Input Properties
The full path where the Excel file should be written. This can be a new file or an existing file (which will be overwritten).
Type: string
Required: Yes
Example: "C:\Data\Output.xlsx" or "D:\Reports\Export.xlsx"
The Excel data as a JSON string. The JSON should be in the format: {"SheetName": {"CellAddress": "Value", ...}, ...}
Type: string
Required: Yes
Example: {"Sheet1": {"A1": "Header1", "B1": "Header2", "A2": "Value1", "B2": "Value2"}}
Note: The JSON must be a valid dictionary structure with sheet names as keys and cell data as nested dictionaries.
Output Properties
True if the file was written successfully, false otherwise.
Type: bool
Note: Returns false if the FilePath is null or empty, if ExcelDataJson is null or empty, if the JSON cannot be deserialized, if the file cannot be written, or if an error occurs.
Usage Example
Scenario: Write data to an Excel file
Configuration:
- FilePath: "C:\Data\Output.xlsx"
- ExcelDataJson: "{\"Sheet1\": {\"A1\": \"Name\", \"B1\": \"Value\", \"A2\": \"Item1\", \"B2\": \"100\"}}"
Result:
- Success: true
Scenario: Write with invalid JSON
Configuration:
- FilePath: "C:\Data\Output.xlsx"
- ExcelDataJson: "invalid json"
Result:
- Success: false
Error Handling
Important: The activity handles errors gracefully:
- If
FilePathis null or empty,Successwill befalse - If
ExcelDataJsonis null or empty,Successwill befalse - If the JSON cannot be deserialized,
Successwill befalse - If the file cannot be written (e.g., permission denied, disk full),
Successwill befalse - If any exception occurs,
Successwill befalse - The activity does not throw exceptions - errors are indicated by the
Successoutput
Always check the Success output to verify if the file was written successfully.
Important Notes
- The FilePath directory must exist and be writable - the activity will not create directories
- If the file already exists, it will be overwritten without warning
- The ExcelDataJson must be valid JSON in the format:
{"SheetName": {"CellAddress": "Value", ...}} - Cell addresses should be in standard Excel format (e.g., "A1", "B2", "Z100")
- Use ReadExcelFile to read data from Excel files
- Ensure the output directory has sufficient disk space for the Excel file
Related Activities
- ReadExcelFile - Read data from an Excel file
- UpdateExcelCell - Update a specific cell in an Excel file
- CreateFile - Create a file
- CreateDirectory - Create a directory for the output file