Download the PHP package adnzaki/excel-creator without Composer
On this page you can find all versions of the php package adnzaki/excel-creator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download adnzaki/excel-creator
More information about adnzaki/excel-creator
Files in adnzaki/excel-creator
Package excel-creator
Short Description A PHPOffice Spreadsheet simplifier
License MIT
Homepage https://github.com/adnzaki/ExcelCreator
Informations about the package excel-creator
ExcelCreator
A simple way to work with PHPSpreadsheet
Introduction
ExcelCreator is an additional tool that enables you to use PHPSpreadsheet
more easily. ExcelCreator simplifies method calls like $spreadsheet->getActiveSheet()->getColumnDimension('A')->setWidth(12)
into $excel->setColumnWidth('A', 12)
.
You may think it does not really help you, but imagine that you have to write code like you usually use in PHPSpreadsheet many times. If you are a lazy programmer, ExcelCreator is a perfect tool to access commonly-used features in PHPSpreadsheet in a convenient way.
Installation
The only thing you need to install ExcelCreator is via Composer with the following options.
With existing composer.json
file
If you have existing composer.json
file, add a requirement pointed to "adnzaki/excel-creator": "^1.0"
And then run composer update
to install it.
No composer.json
file
Run composer require adnzaki/excel-creator
to install it and automatically creates composer.json
file.
Install the latest source code
If you prefer get the latest source code of ExcelCreator, simply change the version from ^1.0
to dev-main
, and then run composer update
to switch the source code.
Usage
This section will guide you how to transform PHPSpreadsheet original use into ExcelCreator
-
Initializing ExcelCreator
-
Call the Xlsx writer
-
Call the Xlsx reader
- Saving excel file to client's browser not get more simple
Note that you have to set Content-Type header before use this method. And also the second parameter should follow the PHPSpreadsheet file type.
- Apply styles into cells
The best way to apply style is using array and pass it as parameter
Styles that have been supported in ExcelCreator are Alignment
, Border
, Color
, Fill
and Font
-
Fill cells with data
ExcelCreator provides simple way to fill cells with your data/value. ExcelCreator uses method chaining from PHPSpreadsheetSpreadsheet::getActiveSheet()->fromArray($value);
- Wrapping text
Wrapping a cell is get easier
Note: Wrapped text can be overridden if you set style array after wrapText()
without
defining wrapText in alignment.
-
Merge and unmerge cells
Although merging and unmerging cells in PHPSpreadsheet is easy, but we make it more simple. - Setting column's width
Have you ever get tired of writing$spreadsheet->getActiveSheet()->getColumnDimension('D')->setWidth(12);
just to set column's width? Here is how ExcelCreator makes it easy for you:
Or if you would like to set some columns with the same size:
And if you would like to set default column's width
- Setting row's height
Setting a row's height is much similar like setting column's width
Or if you would like to set some rows with the same height:
But now setMultipleRowsHeight()
supports more multiple rows:
And if you would like to set default row's height
- Set default font
Setting default font is as easy as follow: