Download the PHP package yii2tech/spreadsheet without Composer

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

Spreadsheet Data Export extension for Yii2


This extension provides ability to export data to spreadsheet, e.g. Excel, LibreOffice etc.

For license information check the LICENSE-file.

Latest Stable Version Total Downloads Build Status

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json.

Usage

This extension provides ability to export data to a spreadsheet, e.g. Excel, LibreOffice etc. It is powered by phpoffice/phpspreadsheet library. Export is performed via \yii2tech\spreadsheet\Spreadsheet instance, which provides interface similar to \yii\grid\GridView widget.

Example:

Please, refer to \yii2tech\spreadsheet\Column class for the information about column properties and configuration specifications.

While running web application you can use \yii2tech\spreadsheet\Spreadsheet::send() method to send a result file to the browser through download dialog:

Multiple sheet files

You can create an output file with multiple worksheets (tabs). For example: you may want to export data about equipment used in the office, keeping monitors, mouses, keyboards and so on in separated listings but in the same file. To do so you will need to manually call \yii2tech\spreadsheet\Spreadsheet::render() method with different configuration before creating final file. For example:

As the result you will get a single *.xls file with 3 worksheets (tabs): 'Monitors', 'Mouses' and 'Keyboards'.

Using \yii2tech\spreadsheet\Spreadsheet::configure() you can reset any spreadsheet parameter, including columns. Thus you are able to combine several entirely different sheets into a single file.

Large data processing

\yii2tech\spreadsheet\Spreadsheet allows exporting of the \yii\data\DataProviderInterface and \yii\db\QueryInterface instances. Export is performed via batches, which allows processing of the large data without memory overflow.

In case of \yii\data\DataProviderInterface usage, data will be split to batches using pagination mechanism. Thus you should setup pagination with page size in order to control batch size:

Note: if you disable pagination in your data provider - no batch processing will be performed.

In case of \yii\db\QueryInterface usage, Spreadsheet will attempt to use batch() method, if it is present in the query class (for example in case \yii\db\Query or \yii\db\ActiveQuery usage). If batch() method is not available - yii\data\ActiveDataProvider instance will be automatically created around given query. You can control batch size via \yii2tech\spreadsheet\Spreadsheet::$batchSize:

Note: despite batch data processing reduces amount of resources needed for spreadsheet file generation, your program may still easily end up with PHP memory limit error on large data. This happens because of large complexity of the created document, which is stored in the memory during the entire process. In case you need to export really large data set, consider doing so via simple CSV data format using yii2tech/csv-grid extension.

Complex headers

You may union some columns in the sheet header into a groups. For example: you may have 2 different data columns: 'Planned Revenue' and 'Actual Revenue'. In this case you may want to display them as a single column 'Revenue', split into 2 sub columns: 'Planned' and 'Actual'. This can be achieved using \yii2tech\spreadsheet\Spreadsheet::$headerColumnUnions. Its each entry should specify 'offset', which determines the amount of columns to be skipped, and 'length', which determines the amount of columns to be united. Other options of the union are the same as for regular column. For example:

Note: only single level of header column unions is supported. You will need to deal with more complex cases on your own.

Custom cell rendering

Before save() or send() method is invoked, you are able to edit generated spreadsheet, making some final adjustments to it. Several methods exist to facilitate this process:

You may use these methods, after document has been composed via \yii2tech\spreadsheet\Spreadsheet::render(), to override or add some content. For example:

Tip: you can use \yii2tech\spreadsheet\Spreadsheet::$rowIndex to get number of the row, which is next to the last rendered one.


All versions of spreadsheet with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version ~2.0.13
phpoffice/phpspreadsheet Version ~1.1
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 yii2tech/spreadsheet contains the following files

Loading the files please wait ....