Download the PHP package lekoala/spread-compat without Composer

On this page you can find all versions of the php package lekoala/spread-compat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package spread-compat

Spread Compat

A unified API for fast CSV, XLSX and ODS import/export in PHP

Powered by Baresheet by default, with adapters for PhpSpreadsheet, OpenSpout, Xlswriter, League CSV and SimpleXLSX.

Why use this ?

Importing/exporting csv data is a very common task in web development. While it's a very efficient format, it's also somewhat difficult for end users that are used to Excel. This is why you often end up accepting also xlsx or ods format as a import/export target.

Ideally, importing single sheets of csv, excel or ods should be just a matter of changing an adapter. Thankfully, this package does just this :-)

Supported packages

Baresheet (recommended/default): the reference adapter for Spread Compat. Fast, memory-efficient CSV, XLSX and ODS import/export with streaming support and a consistent API across all three formats. It covers the typical single-sheet import/export use cases Spread Compat is designed for. https://github.com/lekoala/baresheet

Xlswriter: specialized XLSX performance option backed by the C extension. Particularly useful when maximum XLSX write performance is required. https://github.com/viest/php-ext-xlswriter

OpenSpout: fast csv, excel (xlsx) and ods import/export. A good interoperability option for projects that already use it. https://github.com/openspout/openspout

League CSV: very fast csv import/export. Can read streams. A natural choice for existing League CSV users. https://github.com/thephpleague/csv

PhpSpreadsheet: excel (xls, xlsx) and ods and csv import/export with advanced features such as complex formatting, formulas or workbook manipulation. The only adapter covering legacy .xls. If you need those advanced spreadsheet features, PhpSpreadsheet may be a better fit. https://github.com/PHPOffice/PhpSpreadsheet

SimpleXLSX: lightweight xlsx import/export. A simple alternative for existing users. https://github.com/shuchkin/simplexlsx https://github.com/shuchkin/simplexlsxgen

Baresheet is the reference implementation and the recommended default for CSV, XLSX and ODS. It provides the best overall fit for Spread Compat's single-sheet import/export use case: fast reads and writes, low memory usage, streaming support, and consistent behavior across formats.

Other adapters remain available for projects that already depend on them or need capabilities outside Baresheet's scope.

Using the facade

While you can use individual adapters, it's very likely you don't want to bother too much how your files are read and written. This package provides a simple facade with static methods in order to read and write files.

Please note that read methods return a Generator. If you want an array, you need to use iterator_to_array.

Output to browser

This package includes a simple way to leverage output to browser type of functionnality.

Some adapters allow you to stream directly the response.

For XLSX exports, columnFormats accepts Excel column letters and number format codes. Use @ for text columns such as phone numbers: numeric-looking strings are written as text cells, preserving a leading + or zero. This option is supported by the default Baresheet adapter and PhpSpreadsheet. Baresheet applies the formats while writing, so output() can still stream the XLSX.

With the Baresheet adapter, forceText: true writes every non-empty XLSX or ODS value as spreadsheet text, including numbers, booleans, dates and times. Use it when the columns needing text cannot be identified in advance:

Streaming

Reading and writing already streams row by row: read methods return a Generator and write methods accept any iterable, so large datasets never need to be loaded in memory at once.

For adapters that support it (Baresheet for CSV/XLSX/ODS by default), writeStream() writes the document to a stream resource instead of a filename:

If the selected adapter cannot write to a stream, a BadMethodCallException is thrown. For real browser streaming, use output() instead.

Configure

Using named arguments

This package accepts options using ...opts, this means you can freely use named arguments or pass an array.

Using options object

You can also use the Options class that regroups all available options for all adapters. Options validates option names, while individual adapters silently ignore known options they do not support.

Setting the adapter

Instead of relying on the static variables, you can choose which adapter to use:

Security

CSV Formula Injection

When exporting to CSV, cell values starting with =, +, -, @, \t, or \r can be interpreted as formulas by spreadsheet software like Excel. This is known as CSV Formula Injection.

By default, this library does NOT escape these characters to ensure that the data is not altered and remains compatible with other tools that may expect raw data.

If you are generating CSV files for end users to open in Excel and want to protect them from potential formula injection, you should enable the escapeFormulas option:

This will prepend a single quote (') to any cell value that could be interpreted as a formula.

Worksheets

This package supports only 1 worksheet, as it is meant to be able to replace csv by xlsx or vice versa

Benchmarks

Since we can compare our solutions, there is a built in bench script. You can check the results here

For simple imports/exports, it's very clear that using the Baresheet adapter is the fastest overall choice.


All versions of spread-compat with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1.2
ext-libxml Version *
ext-mbstring Version *
ext-simplexml Version *
ext-xmlreader Version *
ext-zip Version *
lekoala/baresheet Version ^0.9
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lekoala/spread-compat contains the following files

Loading the files please wait ...