Download the PHP package avadim/fast-excel-reader without Composer
On this page you can find all versions of the php package avadim/fast-excel-reader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download avadim/fast-excel-reader
More information about avadim/fast-excel-reader
Files in avadim/fast-excel-reader
Package fast-excel-reader
Short Description Lightweight and very fast XLSX Excel Spreadsheet Reader in PHP
License MIT
Homepage https://github.com/aVadim483/fast-excel-reader
Rated 5.00 based on 1 reviews
Informations about the package fast-excel-reader
FastExcelReader
FastExcelReader is a part of the FastExcelPhp Project which consists of
- FastExcelWriter - to create Excel spreadsheets
- FastExcelReader - to reader Excel spreadsheets
- FastExcelTemplator - to generate Excel spreadsheets from XLSX templates
- FastExcelLaravel - special Laravel edition
Introduction
This library is designed to be lightweight, super-fast and requires minimal memory usage.
FastExcelReader can read Excel compatible spreadsheets in XLSX format (Office 2007+). It only reads data, but it does it very quickly and with minimal memory usage.
Features
- Supports XLSX format only (Office 2007+) with multiple worksheets
- Supports autodetect currency/numeric/date types
- Supports auto formatter and custom formatter of datetime values
- The library can define and extract images from XLSX files
- The library can read styling options of cells - formatting patterns, colors, borders, fonts, etc.
Installation
Use composer
to install FastExcelReader into your project:
Jump to:
- Simple example
- Read values row by row in loop
- Keys in resulting arrays
- Empty cells & rows
- Advanced example
- Date Formatter
- Images functions
- Cell value types
- How to get complete info about the cell style
- Retrieve data validation rules
- Some useful methods
Usage
You can find more examples in /demo folder
Simple example
You will get this array:
You will get this array:
You will get this array:
Read values row by row in loop
Alternative way to read row by row
Keys in resulting arrays
You will get this result:
The optional second argument specifies the result array keys
You will get this result:
Allowed values of result mode
mode options | descriptions |
---|---|
KEYS_ORIGINAL | rows from '1', columns from 'A' (default) |
KEYS_ROW_ZERO_BASED | rows from 0 |
KEYS_COL_ZERO_BASED | columns from 0 |
KEYS_ZERO_BASED | rows from 0, columns from 0 (same as KEYS_ROW_ZERO_BASED + KEYS_COL_ZERO_BASED) |
KEYS_ROW_ONE_BASED | rows from 1 |
KEYS_COL_ONE_BASED | columns from 1 |
KEYS_ONE_BASED | rows from 1, columns from 1 (same as KEYS_ROW_ONE_BASED + KEYS_COL_ONE_BASED) |
Additional options that can be combined with result modes
options | descriptions |
---|---|
KEYS_FIRST_ROW | the same as true in the first argument |
KEYS_RELATIVE | index from top left cell of area (not sheet) |
KEYS_SWAP | swap rows and columns |
For example
You will get this result:
Empty cells & rows
The library already skips empty cells and empty rows by default. Empty cells are cells where nothing is written, and empty rows are rows where all cells are empty. If a cell contains an empty string, it is not considered empty. But you can change this behavior and skip cells with empty strings.
Other way
Advanced example
You can set read area by defined names in workbook. For example if workbook has defined name Headers with range Demo1!$B$4:$D$4 then you can read cells by this name
Note that since the value contains the sheet name, this sheet becomes the default sheet.
You can set read area in the sheet
But if you try to use this name on another sheet, you will get an error
If necessary, you can fully control the reading process using the method with callback-function
Date Formatter
By default, all datetime values returns as timestamp. But you can change this behavior using
Sometimes, if a cell's format is specified as a date but does not contain a date, the library may misinterpret this value. To avoid this, you can disable date formatting
Here, cell B1 contains the string "3.2" and cell B2 contains the date 2024-02-03, but both cells are set to the date format
Images functions
Cell value types
The library tries to determine the types of cell values, and in most cases it does it right. Therefore, you get numeric or string values. Date values are returned as a timestamp by default. But you can change this behavior by setting the date format (see the formatting options for the date() php function).
The above example will output:
The above example will output:
How to get complete info about the cell style
Usually read functions return just cell values, but you can read the values with styles. In this case, for each cell, not a scalar value will be returned, but an array like ['v' => _scalarvalue, 's' => _stylearray, 'f' => formula]
Or you can read styles only (without values)
But we do not recommend using these methods with large files
Retrieve data validation rules
Every sheet in your XLSX file can contain a set of data validation rules. To retrieve them, you can imply call getDataValidations
on your sheet
Support merged cells
You can use the following methods:
- -- Returns all merged ranges
- -- Checks if a cell is merged
- -- Returns merge range of specified cell
For example
Some useful methods
Excel object
- -- Returns names array of all sheets
- -- Returns default or specified sheet
- -- Get sheet by name
- -- Get sheet by id
- -- Get the first sheet
- -- Select default sheet by name and returns it
- -- Select default sheet by id and returns it
- -- Select the first sheet as default and returns it
- -- Returns defined names of workbook
Sheet object
- -- Returns name of string
- -- Active worksheet
- -- If worksheet is hidden
- -- If worksheet is visible
- -- Returns string state of worksheet (used in and )
- -- Returns dimension of default work area from sheet properties
- -- Count rows from dimension
- -- Count columns from dimension
- -- The first row number
- -- The first column letter
- -- Returns values of cells of 1st row as array
- -- Returns values and styles of cells of 1st row as array
Do you want to support FastExcelReader?
if you find this package useful you can give me a star on GitHub.
Or you can donate me :)
- USDT (TRC20) TSsUFvJehQBJCKeYgNNR1cpswY6JZnbZK7
- USDT (ERC20) 0x5244519D65035aF868a010C2f68a086F473FC82b
- ETH 0x5244519D65035aF868a010C2f68a086F473FC82b
All versions of fast-excel-reader with dependencies
ext-zip Version *
ext-mbstring Version *
ext-ctype Version *
ext-xmlreader Version *
avadim/fast-excel-helper Version ^1.1