PHPackages                             boundstate/yii2-importexport - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. boundstate/yii2-importexport

ActiveYii2-extension[PDF &amp; Document Generation](/categories/documents)

boundstate/yii2-importexport
============================

Extension for the Yii2 framework for importing and exporting data

v0.0.3(9y ago)2655MITPHP

Since May 25Pushed 9y ago2 watchersCompare

[ Source](https://github.com/boundstate/yii2-importexport)[ Packagist](https://packagist.org/packages/boundstate/yii2-importexport)[ RSS](/packages/boundstate-yii2-importexport/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

yii2-importexport
=================

[](#yii2-importexport)

Extension for the Yii2 framework for importing and exporting data with [PHPExcel](https://github.com/PHPOffice/PHPExcel).

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist boundstate/yii2-importexport "*"

```

or add

```
"boundstate/yii2-importexport": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Implement the `ImportInterface` and/or `ExportInterface`:

```
class Contact extends \yii\db\ActiveRecord implements ImportInterface, ExportInterface
{
    ...

    public function import($reader, $row, $data)
	{
	    if ($row == 0) {
	        if ($data != ['First Name', 'Last Name', 'Email']) {
	            $reader->addError($row, 'Invalid headers.');
	            return false;
	        }
	        // Skip header row
	        return true;
	    }

	    // Create contact from data
	    $contact = new Contact;
	    ...
    }

    public function export() {
        return self::find()->asArray()->all();
    }
}

```

Now you can import data using `ExcelReader` and your class as the `destination`:

```
public function actionImport()
{
    $form = new ImportForm();
    $form->file = UploadedFile::getInstanceByName('file');

    if ($form->validate()) {
        Contact::deleteAll();
        $reader = new ExcelReader(['destination' => Contact::className()]);
        $reader->import($form->file->tempName);
        if ($reader->getErrors()) {
            // Handle errors
            ...
        }
    }
    return $form;
}

```

Or export data using `ExcelWriter` and your class as the `source`:

```
public function actionExport()
{
	$writer = new ExcelWriter(['source' => Contact::className()]);
    $filename = $writer->write('Excel2007');
    Yii::$app->response->sendFile($filename, 'contacts.xlsx')->send();
}

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~223 days

Total

3

Last Release

3566d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c8f627574f6bee1e622a2c9ada35d4347e67f6c92377bb80045c7c6661f390c?d=identicon)[mikejpeters](/maintainers/mikejpeters)

---

Top Contributors

[![mikejpeters](https://avatars.githubusercontent.com/u/3334654?v=4)](https://github.com/mikejpeters "mikejpeters (3 commits)")

---

Tags

excelxlsxlsxcsvPhpOfficePHPExcelyii2

### Embed Badge

![Health badge](/badges/boundstate-yii2-importexport/health.svg)

```
[![Health](https://phpackages.com/badges/boundstate-yii2-importexport/health.svg)](https://phpackages.com/packages/boundstate-yii2-importexport)
```

###  Alternatives

[avadim/fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP

2951.2M7](/packages/avadim-fast-excel-writer)[phpnt/yii2-export

Yii2 It saves data in xls, csv, word, html, pdf files.

158.9k](/packages/phpnt-yii2-export)[jianyan74/php-excel

php excel 导入导出

5842.2k4](/packages/jianyan74-php-excel)[jgrygierek/batch-entity-import-bundle

Importing entities with preview and edit features for Symfony.

101.1M1](/packages/jgrygierek-batch-entity-import-bundle)[jgrygierek/sonata-batch-entity-import-bundle

Importing entities with preview and edit features for Sonata Admin.

10951.2k](/packages/jgrygierek-sonata-batch-entity-import-bundle)[infostreams/excel-merge

A PHP library to merge two or more Excel files into one

3858.2k1](/packages/infostreams-excel-merge)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
