labelworx/excel-converter

Quickly convert XLSX, XLS or delimited files such as CSV, TSV, Semi Colon, Pipe Delimited or files with any bespoke delimiter of your choosing to a delimited file.

1.4.3 2022-09-28 08:46 UTC

This package is auto-updated.

Last update: 2024-03-28 12:23:23 UTC


README

This package allows you to quickly convert XLSX, XLS or delimited files such as CSV, TSV, Semi Colon, Pipe Delimited or files with any bespoke delimiter of your choosing to a delimited file.

Installation

Require the package using composer:

composer require labelworx/excel-converter

Usage

use LabelWorx\ExcelConverter\ExcelConverter;

$excel = new ExcelConverter();

// Simple Conversions
$excel->source('path/to/input.xls')->toCSV('path/to/output.csv');
$excel->source('path/to/input.xlsx')->toTSV('path/to/output.tsv');
$excel->source('path/to/input.csv')->toTSV('path/to/output.tsv');
$excel->source('path/to/input.tsv')->toCSV('path/to/output.csv');

// Converts Pipe delimited file to Semi-Colon delimited file by passing delimiters
$excel->source('path/to/input.txt', '|')->to('path/to/output.txt', ';');

// For Excel source files you can specify a worksheet by name or number
$excel->source('path/to/input.xls')->worksheet('Sheet 2')->toCSV('path/to/output.csv');
$excel->source('path/to/input.xlsx')->worksheet(2)->toTSV('path/to/output.tsv');

// For Excel source files you can also specify an export date format
$excel->source('path/to/input.xls')->exportDateFormat('d/m/Y')->toCSV('path/to/output.csv');
$excel->source('path/to/input.xlsx')->exportDateFormat('d/m/Y')->toTSV('path/to/output.tsv');

Laravel Usage

For Laravel users there is the option of using a Facade.

use LabelWorx\ExcelConverter\Facades\ExcelConverter;

ExcelConverter::source('path/to/input.xls')->toCSV('path/to/output.csv');

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT