# Excel to CSV Converter (`web.harvester/excel-to-csv`) Actor

Convert Excel files (XLSX, XLS, ODS) to CSV format. Extract all sheets or specific ones. Configurable delimiter, date formatting, skip empty rows. Batch processing multiple files. Optional JSON output to Dataset. Handles large files efficiently. Perfect for ETL pipelines.

- **URL**: https://apify.com/web.harvester/excel-to-csv.md
- **Developed by:** [Web Harvester](https://apify.com/web.harvester) (community)
- **Categories:** Automation, Developer tools, Integrations
- **Stats:** 4 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#rental-actors

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Excel to CSV Converter

> 📊 Convert Excel files (XLSX, XLS) to CSV format. Handle multiple sheets, large files, and batch processing. Perfect for ETL pipelines and data integration.

[![Apify Actor](https://img.shields.io/badge/Apify-Actor-blue)](https://apify.com)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

### 🎯 What This Actor Does

A robust Excel to CSV converter that:

- **Converts XLSX and XLS** files to standard CSV format
- **Handles multiple sheets** - extract all or specific sheets
- **Processes large files** - memory-efficient streaming
- **Preserves data types** - dates, numbers, text formatted correctly
- **Batch processing** - convert multiple files at once

### 🚀 Use Cases

| Use Case | Description |
|----------|-------------|
| **ETL Pipelines** | Transform Excel exports for data warehouses |
| **Data Migration** | Convert legacy Excel databases |
| **API Integration** | Excel → CSV → JSON for APIs |
| **Reporting** | Standardize financial reports |
| **Data Analysis** | Prepare data for Pandas, R, SQL |
| **Automation** | Process daily Excel email attachments |

### 📥 Input Options

#### Upload Directly

Drag and drop your Excel file in the Apify Console.

#### Provide URL

```json
{
    "fileUrl": "https://example.com/report.xlsx"
}
```

#### Batch Processing

```json
{
    "fileUrls": [
        "https://example.com/report-q1.xlsx",
        "https://example.com/report-q2.xlsx",
        "https://example.com/report-q3.xlsx"
    ]
}
```

### ⚙️ Configuration

#### File Input

| Parameter | Type | Description |
|-----------|------|-------------|
| `file` | string | Upload file directly |
| `fileUrl` | string | URL to Excel file |
| `fileUrls` | array | Multiple file URLs |

#### Sheet Selection

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `allSheets` | boolean | `true` | Convert all sheets |
| `sheets` | array | `[]` | Specific sheet names or indices |

#### CSV Options

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `delimiter` | string | `,` | Field separator: `,` `;` `\t` `\|` |
| `includeHeaders` | boolean | `true` | First row is headers |
| `dateFormat` | string | `YYYY-MM-DD` | Date formatting (dayjs) |
| `skipEmptyRows` | boolean | `true` | Omit blank rows |

#### Output Options

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `outputToDataset` | boolean | `false` | Also push rows as JSON |

### 📤 Output

#### Dataset (Metadata)

```json
{
    "fileName": "sales-report.xlsx",
    "sheetName": "Q1 Sales",
    "sheetIndex": 0,
    "rowCount": 1523,
    "columnCount": 12,
    "csvUrl": "https://api.apify.com/v2/key-value-stores/.../records/sales_q1.csv",
    "status": "success",
    "convertedAt": "2024-01-15T10:30:00.000Z"
}
```

#### Key-Value Store (CSV Files)

Download CSV files directly from the Key-Value Store.

### 🚀 Quick Start

#### Using Apify Console

1. Upload your Excel file or enter URL
2. Configure sheet and CSV options
3. Click **Start**
4. Download CSVs from **Storage** → **Key-Value Store**

#### Using API

```bash
curl -X POST "https://api.apify.com/v2/acts/YOUR_USERNAME~excel-to-csv/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "fileUrl": "https://example.com/data.xlsx",
    "allSheets": true,
    "delimiter": ","
  }'
```

#### Using JavaScript

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_TOKEN' });

const run = await client.actor('YOUR_USERNAME/excel-to-csv').call({
    fileUrl: 'https://example.com/quarterly-report.xlsx',
    allSheets: true,
    delimiter: ',',
    dateFormat: 'YYYY-MM-DD'
});

// Get conversion results
const { items } = await client.dataset(run.defaultDatasetId).listItems();

for (const item of items) {
    console.log(`Sheet: ${item.sheetName}`);
    console.log(`Rows: ${item.rowCount}`);
    console.log(`Download: ${item.csvUrl}`);
}
```

#### Using Python

```python
from apify_client import ApifyClient
import pandas as pd

client = ApifyClient('YOUR_TOKEN')

## Convert Excel to CSV
run = client.actor('YOUR_USERNAME/excel-to-csv').call(run_input={
    'fileUrl': 'https://example.com/data.xlsx'
})

## Get CSV URLs
items = client.dataset(run['defaultDatasetId']).list_items().items

## Load into pandas
for item in items:
    if item['status'] == 'success':
        df = pd.read_csv(item['csvUrl'])
        print(f"Loaded {item['sheetName']}: {len(df)} rows")
```

### 💡 Advanced Examples

#### Extract Specific Sheets

```json
{
    "fileUrl": "https://example.com/workbook.xlsx",
    "allSheets": false,
    "sheets": ["Summary", "Data", "0"]
}
```

*Note: You can use sheet names or zero-based indices*

#### European CSV Format

```json
{
    "fileUrl": "https://example.com/report.xlsx",
    "delimiter": ";",
    "dateFormat": "DD.MM.YYYY"
}
```

#### Output as JSON Dataset

```json
{
    "fileUrl": "https://example.com/customers.xlsx",
    "outputToDataset": true,
    "includeHeaders": true
}
```

This adds each row as a JSON object to the Dataset:

```json
{
    "_sheet": "Customers",
    "_file": "customers.xlsx",
    "Name": "John Doe",
    "Email": "john@example.com",
    "SignupDate": "2024-01-15"
}
```

### 📊 Supported Formats

| Format | Extension | Support |
|--------|-----------|---------|
| Excel 2007+ | .xlsx | ✅ Full |
| Excel 97-2003 | .xls | ✅ Full |
| OpenDocument | .ods | ✅ Full |
| CSV (input) | .csv | ✅ Full |
| Numbers | .numbers | ⚠️ Limited |

### 💰 Cost Estimation

| File Size | Sheets | Approx. Time | Compute Units |
|-----------|--------|--------------|---------------|
| 1 MB | 3 | ~5 seconds | ~0.002 |
| 10 MB | 5 | ~15 seconds | ~0.008 |
| 50 MB | 10 | ~45 seconds | ~0.03 |
| 100 MB | 20 | ~2 minutes | ~0.08 |

### 🔧 Technical Details

- **Node.js:** 22.x
- **Library:** SheetJS (xlsx)
- **Max File Size:** ~200MB recommended
- **Memory:** 512MB-2GB depending on file size

### ⚠️ Limitations

- **Formulas:** Values only (not formula text)
- **Formatting:** Lost in CSV conversion
- **Merged Cells:** Unmerged, value in first cell
- **Images/Charts:** Not extracted
- **Password Protected:** Not supported

### ❓ FAQ

#### How are dates handled?

Dates are converted using the `dateFormat` parameter (default: `YYYY-MM-DD`). Uses dayjs formatting.

#### What about number formatting?

Numbers are extracted as raw values. Currency symbols and formatting are removed.

#### Can I convert password-protected files?

No, password-protected Excel files are not currently supported.

#### What's the maximum file size?

Recommended max is ~200MB. Larger files may timeout or run out of memory.

### 🔗 Integration Pipeline

```javascript
// 1. Fetch Excel from email/S3/API
const excelUrl = await fetchLatestReport();

// 2. Convert to CSV
const convertRun = await client.actor('YOUR_USERNAME/excel-to-csv').call({
    fileUrl: excelUrl,
    outputToDataset: true
});

// 3. Load into database
const { items } = await client.dataset(convertRun.defaultDatasetId).listItems();
await database.insertMany(items);

// 4. Notify completion
await sendSlackNotification(`Imported ${items.length} rows`);
```

### 📄 License

MIT License - see [LICENSE](LICENSE) for details.

# Actor input Schema

## `file` (type: `string`):

Upload an Excel file (.xlsx, .xls) to convert

## `fileUrl` (type: `string`):

Direct URL to an Excel file

## `fileUrls` (type: `array`):

Convert multiple Excel files at once

## `allSheets` (type: `boolean`):

Process all sheets in the workbook

## `sheets` (type: `array`):

Sheet names or indices (0-based) to convert. Only used if 'Convert All Sheets' is disabled.

## `delimiter` (type: `string`):

Character to separate fields in the output CSV

## `includeHeaders` (type: `boolean`):

Treat the first row as column headers

## `dateFormat` (type: `string`):

Format for date cells (e.g., YYYY-MM-DD, MM/DD/YYYY, DD.MM.YYYY)

## `skipEmptyRows` (type: `boolean`):

Omit rows where all cells are empty

## `outputToDataset` (type: `boolean`):

Push each row as a JSON object to the Dataset (in addition to CSV files)

## Actor input object example

```json
{
  "fileUrl": "https://go.microsoft.com/fwlink/?LinkID=521962",
  "allSheets": true,
  "delimiter": ",",
  "includeHeaders": true,
  "dateFormat": "YYYY-MM-DD",
  "skipEmptyRows": true,
  "outputToDataset": false
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "fileUrl": "https://go.microsoft.com/fwlink/?LinkID=521962"
};

// Run the Actor and wait for it to finish
const run = await client.actor("web.harvester/excel-to-csv").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "fileUrl": "https://go.microsoft.com/fwlink/?LinkID=521962" }

# Run the Actor and wait for it to finish
run = client.actor("web.harvester/excel-to-csv").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "fileUrl": "https://go.microsoft.com/fwlink/?LinkID=521962"
}' |
apify call web.harvester/excel-to-csv --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=web.harvester/excel-to-csv",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Y3WVtH70A9WlGxjRQ/builds/SHDEUvkAgNr3d4KpD/openapi.json
