Skip to content

yawalkar/FlowMattic-XLSX-Conversion-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FlowMattic XLSX Conversion API

A WordPress plugin that provides XLSX to CSV/JSON conversion functionality for FlowMattic workflows using the PHP Functions module.

Overview

This plugin registers a custom PHP function flowmattic_convert_xlsx that can be called directly from FlowMattic's PHP Functions action step to convert XLSX files to CSV or JSON format with streaming support.

Features

  • Convert XLSX files to CSV or JSON format
  • Streaming support for large files
  • Easy integration with FlowMattic workflows
  • Powered by PHPSpreadsheet library
  • Memory-efficient processing

Installation

  1. Upload the flowmattic-xlsx-conversion-api folder to your /wp-content/plugins/ directory
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. The function flowmattic_convert_xlsx will be automatically available for use in FlowMattic workflows

Usage in FlowMattic Workflow

Step 1: Add PHP Functions Action

In your FlowMattic workflow, add a PHP Functions action step.

Step 2: Configure the Function

In the PHP Functions configuration screen:

Function Name

flowmattic_convert_xlsx

Function Parameters Type

Select: Individual Variable

This ensures each parameter is passed separately to the function.

Function Parameters

Add two parameters:

  1. Parameter 1:

    • Key: file_url
    • Value: Your XLSX file URL (can be a dynamic value from previous steps)
    • Example: https://domain.com/files/data.xlsx
  2. Parameter 2:

    • Key: conversion_type
    • Value: csv or json
    • Options:
      • csv - Convert to CSV format
      • json - Convert to JSON format

JSON Value Decode

Select: Pass as it is

Step 3: Example Configuration

Function Name: flowmattic_convert_xlsx

Function Parameters:
- file_url: https://domain.com/files/data.xlsx
- conversion_type: csv

Step 4: Test the Function

Click the Test button to verify the conversion works correctly.

Function Response

The function returns a JSON response with the following structure:

Success Response

{
  "status": "success",
  "data": "...converted data...",
  "format": "csv"
}

or for JSON format:

{
  "status": "success",
  "data": [...array of rows...],
  "format": "json"
}

Error Response

{
  "status": "error",
  "message": "Error description"
}

Using the Response in Next Steps

After the PHP Functions step, you can access the response data in subsequent workflow steps:

  • Full Response: {{step_id.response}}
  • Status: {{step_id.response.status}}
  • Data: {{step_id.response.data}}
  • Format: {{step_id.response.format}}

Replace step_id with the actual ID of your PHP Functions step.

CSV Output Format

The CSV output includes:

  • Header row with column names
  • Data rows with values
  • Proper escaping of special characters
  • UTF-8 encoding with BOM for Excel compatibility

JSON Output Format

The JSON output is structured as an array of objects:

[
  {
    "Column1": "Value1",
    "Column2": "Value2",
    "Column3": "Value3"
  },
  {
    "Column1": "Value4",
    "Column2": "Value5",
    "Column3": "Value6"
  }
]

Requirements

  • WordPress 5.0 or higher
  • FlowMattic plugin installed and activated
  • PHP 8.1 or higher
  • PHP extensions: zip, xml, gd, mbstring

Common Use Cases

1. XLSX to CSV Conversion

Convert uploaded XLSX files to CSV format for processing or import into other systems.

2. XLSX to JSON Conversion

Extract data from XLSX files as JSON for API integrations or database operations.

3. Data Processing Pipeline

Combine with other FlowMattic actions to:

  • Upload XLSX file
  • Convert to CSV/JSON
  • Process the data
  • Store in database or send to external service

Troubleshooting

Function Not Found

  • Ensure the plugin is activated
  • Check that FlowMattic is properly installed

Conversion Fails

  • Verify the file URL is accessible
  • Check that the file is a valid XLSX format
  • Ensure sufficient server memory for large files

Empty Response

  • Check if the XLSX file has data
  • Verify the file permissions allow reading

Support

For issues or questions, please open an issue on the GitHub repository.

License

This plugin is provided as-is for use with FlowMattic workflows.

Credits

Built with:

Built For:

About

A plugin to convert XLSX files to CSV or JSON. CSV is uploaded to the media library, and you can then use the CSV Parse by FlowMattic in your workflow.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages