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

FilePath

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"

ExcelDataJson

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

Success

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 FilePath is null or empty, Success will be false
  • If ExcelDataJson is null or empty, Success will be false
  • If the JSON cannot be deserialized, Success will be false
  • If the file cannot be written (e.g., permission denied, disk full), Success will be false
  • If any exception occurs, Success will be false
  • The activity does not throw exceptions - errors are indicated by the Success output

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