Download the PHP package lekoala/baresheet without Composer

On this page you can find all versions of the php package lekoala/baresheet. 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 baresheet

Baresheet

Fast, zero-dependency CSV, XLSX, and ODS reader/writer for PHP.

Requirements

Format Specific (Required for XLSX/ODS)

Optional

Installation

Quick Start

Direct Reader/Writer Usage

Concrete classes allow setting properties directly or passing an Options object to the constructor:

Features

CSV

XLSX

ODS

Options

There are two ways to pass options:

1. Directly on instances:

2. Options object (works on any method, including the Baresheet facade). The constructor provides full IDE autocomplete:

Option Type Default Applies to
assoc bool false Read (All)
strict bool false Read (CSV, XLSX, ODS)
stream bool true Output (Any)
limit ?int null Read (All)
offset int 0 Read (All)
skipEmptyLines bool true Read (All)
headers string[] [] Write (All), Read (CSV)
separator string "auto" Read (CSV)
enclosure string " Read (CSV)
escape string "" Read (CSV)
eol string \r\n Write (CSV)
inputEncoding ?string null Read (CSV)
outputEncoding ?string null Read/Write (CSV)
bom bool|string|Bom true Write (CSV)
escapeFormulas bool/callable false Write (CSV)
meta array/Meta null Write (XLSX, ODS)
autofilter ?string null Write (XLSX)
freezePane ?string null Write (XLSX)
sheet string/int null Read/Write (XLSX, ODS)
boldHeaders bool false Write (XLSX, ODS)
tempPath ?string null Any (Temp files location)
sharedStrings bool false Write (XLSX)
autoWidth bool false Write (XLSX)
requiredColumns string[] [] Read (CSV, XLSX, ODS)
columns string[] [] Read (CSV, XLSX, ODS)

Required Columns Validation

Validate that input files contain expected columns before processing. This catches malformed files early, avoiding wasted cycles parsing invalid data.

The validation occurs immediately after reading the header row and throws a descriptive exception listing the missing columns:

Works with all reader formats (CSV, XLSX, ODS) and the Baresheet facade.

Column Selection

Select and reorder specific columns when reading. This is useful for wide files where you only need a subset of columns, or when you need columns in a specific order. Selected columns must exist in the file headers (they are implicitly required).

Reordering Columns

Column selection also allows reordering:

Plain Mode with Column Selection

When using assoc: false, provide explicit headers and receive values in plain arrays:

Working with Headerless Files

When reading files without header rows, you can inject column names using the headers option. This enables column selection and associative output even for plain data files:

This works with all reader formats (CSV, XLSX, ODS) and is useful when:

Column selection provides dramatic performance improvements for XLSX and ODS files by skipping XML parsing for unselected cells. For CSV, it provides a zero-overhead "direct indexing" fast path that avoids intermediate array allocations.

Format 20 columns → 5 columns Speedup Memory/CPU Savings
XLSX 2.94s → 1.33s ~2.2x faster High (Skips XML Nodes)
ODS 1.80s → 1.25s ~1.4x faster High (Skips XML Nodes)
CSV 0.28s → 0.28s Baseline 90%+ fewer hash-table entries

[!TIP] The CSV "Practical Ceiling": While CSV reading cannot skip bytes (as fgetcsv must tokenize every field to track quotes/delimiters), Baresheet uses a direct numeric indexing map. This avoids creating a full associative array for the entire row before subsetting, effectively reaching the maximum performance possible for column selection in PHP.

Error Handling

Missing columns throw immediately:

Data Transformation

Baresheet preserves raw cell values by design. For cleaning, casting, or filtering, use the Transform class — generator-based pipelines that compose with readers and writers without loading data into memory.

Streaming Output

For large files, streaming avoids writing a temporary file to disk. Baresheet streams output() by default.

However, keep in mind that streaming changes how data is sent to the browser. Because the total file size is unknown before the transfer starts, the server cannot send a Content-Length header. This means the browser download will not display a progress bar or an estimated time of completion.

To bypass streaming and force buffering, use stream: false with output(). Baresheet will buffer the file (either in memory for CSV, or via a temporary zip file for XLSX/ODS) to precisely calculate and send the Content-Length header along with it.

Note on XLSX/ODS: Streaming requires an optional dependency. Install it with:

If the zipstream-php dependency is missing, Baresheet will seamlessly and automatically fall back to buffered output.

PSR-7 / Response Objects (Symfony, Laravel)

To avoid breaking the flow of your application or sending explicit header() calls directly, you should create a Response object when applicable in your framework.

Use the writeStream() method to generate the spreadsheet as a memory-capped php://temp stream resource, and feed it into your Response class:

Symfony / Laravel (StreamedResponse)

PSR-7 (Guzzle, Nyholm, etc.)

Performance

Baresheet is explicitly engineered to minimize server resource footprint.

The XLSX and ODS readers use an optimized XMLReader approach that opens zip:// streams directly. This avoids any temporary file extraction, cutting I/O overhead by 50% compared to standard zip extraction methods.

Here are the results extracting/writing 50,000 rows (4 columns) locally against other common industry standard libraries:

Reading (Parsing) 50,000 Rows

Reading CSV

Library Avg Time (s) Peak Memory (MB)
Baresheet (CSV) 0.0057 0.63
League (CSV) 0.0089 0.63
OpenSpout (CSV) 0.0201 0.63

Reading XLSX

Library Avg Time (s) Peak Memory (MB)
Baresheet (XLSX) 0.0391 0.63
SimpleXLSX (XLSX) 0.0816 5.78
OpenSpout (XLSX) 0.2114 0.63

Reading ODS

Library Avg Time (s) Peak Memory (MB)
Baresheet (ODS) 0.0484 0.63
OpenSpout (ODS) 0.1592 0.63

Writing 50,000 Rows

Writing CSV

Library Avg Time (s) Peak Memory (MB)
Baresheet (CSV) 0.0956 0.50
League (CSV) 0.1288 0.55
OpenSpout (CSV) 0.2770 0.47

Writing XLSX

Library Avg Time (s) Peak Memory (MB)
Baresheet (XLSX) 0.4504 0.79
Baresheet (XLSX - Auto Width) 0.4429 0.79
SimpleXLSXGen (XLSX) 0.6612 109.77
Baresheet (XLSX - Shared Strings) 0.8780 34.26
OpenSpout (XLSX) 0.9011 1.01
Baresheet (XLSX - Full) 0.9351 34.26

Note: By default, Baresheet uses the fastest mode (shared strings and auto column width disabled). You can re-enable them via Options.

Writing ODS

Library Avg Time (s) Peak Memory (MB)
Baresheet (ODS) 0.7693 0.93
OpenSpout (ODS) 1.2474 0.88

Security Considerations

CSV Formula Injection

When writing CSV files, any cell beginning with =, +, -, or @ could be interpreted as a formula if the file is opened in spreadsheet software like Microsoft Excel. A maliciously crafted input could lead to execution of arbitrary functions or system commands on the user's local machine.

By default, Baresheet prioritizes data round-trip integrity. Attempting to automatically prefix formulas with a single quote (') to disable formula execution corrupts otherwise valid user inputs.

If you are exporting data to be consumed by clients opening the file in Excel, you must opt-in to the protection logic:

Selective Formula Escaping

For advanced use cases, escapeFormulas also accepts a callable that receives the cell value and column index, allowing you to selectively escape only specific columns:

Important: Heuristic detection of "malicious" formulas is fundamentally unreliable. Attackers can use CHAR() functions to build strings character-by-character, and new attack vectors emerge constantly. The library takes a conservative approach: blanket escaping by default when enabled, or user-controlled selective escaping via callback. For maximum security with user-generated content, prefer XLSX format, which has explicit cell type metadata and is immune to formula injection.

License

MIT


All versions of baresheet 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 *
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/baresheet contains the following files

Loading the files please wait ...