Download the PHP package yidas/phpspreadsheet-helper without Composer
On this page you can find all versions of the php package yidas/phpspreadsheet-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yidas/phpspreadsheet-helper
More information about yidas/phpspreadsheet-helper
Files in yidas/phpspreadsheet-helper
Package phpspreadsheet-helper
Short Description PHP Excel Helper - Write and read Spreadsheet with easy way based on PhpSpreadsheet
License MIT
Homepage https://github.com/yidas/phpspreadsheet-helper
Informations about the package phpspreadsheet-helper
PHPSpreadsheet Helper
PHP Excel Helper - Write and read Spreadsheet with easy way based on PhpSpreadsheet
This library is a helper that encapsulate PhpSpreadsheet (Documentation) for simple usage.
OUTLINE
- Demonstration
- Installation
- Requirements
- Usage
- Import & Export
- newSpreadsheet()
- output()
- save()
- Get Rows
- getRow()
- getRows()
- Add Rows
- addRow()
- addRows()
- Attributes
- PhpSpreadsheet Original Usage Integration
- Inject PhpSpreadsheet
- Extract PhpSpreadsheet
- Merge Cells
- Multiple Sheets
- setSheet()
- getSheet()
- Map of Coordinates & Ranges
- Style Attributes
- Columns Format
- All Cells Format
- setStyle()
- setWrapText()
- setAutoSize()
- Limitations
- Performance Issue
DEMONSTRATION
Write to Excel
Output an Excel file to browser for download:
Read from Excel
Import above excel file and return two-dimensional array data contained rows > columns spread sheet:
Output result:
REQUIREMENTS
This library requires the following:
- Dependent on PhpSpreadsheet
- PHP 5.6.0+
- PHP extension php-zip enabled
- PHP extension php-xml enabled
- PHP extension php-gd2 enabled (if not compiled in)
INSTALLATION
Run Composer in your project:
composer require yidas/phpspreadsheet-helper
Then you could call it after Composer is loaded depended on your PHP framework:
USAGE
Import & Export
Simpliy read an Excel file then output to browser:
newSpreadsheet()
New or load an PhpSpreadsheet object
output()
Output file to browser
$format
list: Xlsx
, Xls
, Html
, Csv
, Ods
save()
Save as file
Example:
Get Rows
getRow()
Get data of a row from the actived sheet of PhpSpreadsheet
Example:
Example of fetching content per each row (Example Code):
getRows()
Get rows from the actived sheet of PhpSpreadsheet
Example of getRows()
Add Rows
addRow()
Add a row to the actived sheet of PhpSpreadsheet
$rowData
value: An array contains string or array of attributes for each cell
$rowAttributes
value: string or array of attributes for each cell of a row
Example of addRow()
Example of setting attributes for each cell:
Example of setting attributes for each row:
addRows()
Add rows to the actived sheet of PhpSpreadsheet
$data
value: array of each $rowData from addRow()
$rowAttributes
value: string or array of attributes for each row
Example of addRows()
Attributes
Attributes is a standard array for defining a cell or even a row, the keys are as follows:
key
, value
, style
PhpSpreadsheet Original Usage Integration
This helper is flexible that you could inject or extract original PhpSpreadsheet with it, when you need to manipulate some Phpspreadsheet methods integrated with Helper.
Inject PhpSpreadsheet
Extract PhpSpreadsheet
Merge Cells
It's easy to merge cells by defining each cell's span attributes:
row
: Number of rowspan cells to merge withcol
: Number of colspan cells to merge withskip
: Number of colspan cells to merge with
Multiple Sheets
setSheet()
Set an active PhpSpreadsheet Sheet
getSheet()
Get PhpSpreadsheet Sheet object from cache
Example:
getActiveSheetIndex()
: Get active sheet indexgetSheetCount()
: Get sheet count
Map of Coordinates & Ranges
The result could be:
Style Attributes
The style attribute could be set on a range of cells.
style
: a attribute refers toapplyFromArray()
for styling
Style array key/value/constant refers Valid array keys for style
applyFromArray()
or Source Classes
Columns Format
The options for each cell data:
width
: setWidth() for the column
All Cells Format
This section focuses on applying all actived cells or ranged cells on the sheet, not just effecting single cell, row or column.
setStyle()
Set Style for all actived cells or set by giving range to the actived sheet
Example:
setWrapText()
Set WrapText for all actived cells or set by giving range to the actived sheet
setAutoSize()
Set AutoSize for all actived cells or set by giving column range to the actived sheet
LIMITATIONS
Performance Issue
If you're building large cell data with XLSX, you may face performance issue with memory usage and execution time.
box/spout spreadsheet lirary supports building Excel file with high performance, you could use this library instead if you do not need more style and formatting requirements.