Action that creates Excel files from JSON data Supports multiple sheets, formatting, and formulas

Example

// Create simple Excel with one sheet
await runAction({
ActionName: 'Excel Writer',
Params: [{
Name: 'Sheets',
Value: [{
name: 'Sales Data',
data: [
{ Product: 'Widget A', Sales: 100, Revenue: 1000 },
{ Product: 'Widget B', Sales: 150, Revenue: 1500 }
]
}]
}]
});

// Create Excel with multiple sheets and formatting
await runAction({
ActionName: 'Excel Writer',
Params: [{
Name: 'Sheets',
Value: [{
name: 'Q1 Sales',
data: salesData,
headers: ['Product', 'Units', 'Revenue'],
columnWidths: [20, 10, 15],
styles: {
headerStyle: { font: { bold: true }, fill: { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FF4472C4' } } }
}
}, {
name: 'Summary',
data: summaryData
}]
}]
});

Hierarchy

  • BaseFileHandlerAction
    • ExcelWriterAction

Constructors

Methods

  • Creates Excel files from JSON data

    Parameters

    • params: RunActionParams<any>

      The action parameters containing:

      • Sheets: Array of sheet definitions, each containing:
        • name: Sheet name (required)
        • data: Array of data rows (required)
        • headers: Array of column headers (optional, derived from data if not provided)
        • columnWidths: Array of column widths in characters (optional)
        • styles: Object with style definitions (optional)
        • formulas: Array of formula definitions (optional)
      • OutputFileID: Optional MJ Storage file ID to save to
      • FileName: Name for the generated Excel file (default: 'workbook.xlsx')
      • Author: Author metadata (optional)
      • Title: Title metadata (optional)
      • Description: Description metadata (optional)

    Returns Promise<ActionResultSimple>

    Base64 encoded Excel data or FileID if saved

  • Executes the action with the provided parameters.

    Parameters

    • params: RunActionParams<any>

      The action execution parameters including context

    Returns Promise<ActionResultSimple>

    Promise resolving to the action result

  • Get file content from various sources based on parameters Priority: FileID > FileURL > Data parameter

    Parameters

    • params: RunActionParams<any>

      Action parameters

    • dataParamName: string

      Name of the parameter containing direct data

    • fileParamName: string = 'FileID'

      Name of the parameter containing file ID (default: 'FileID')

    • urlParamName: string = 'FileURL'

      Name of the parameter containing file URL (default: 'FileURL')

    Returns Promise<{
        content: string | Buffer;
        fileName?: string;
        mimeType?: string;
        source: "url" | "storage" | "direct";
    }>

    Object with content and metadata

  • Populate worksheet with data

    Parameters

    • worksheet: Worksheet
    • sheetDef: any

    Returns {
        columnCount: number;
        rowCount: number;
    }

    • columnCount: number
    • rowCount: number