PHPackages                             xpbl4/yii2-import-export - 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. xpbl4/yii2-import-export

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

xpbl4/yii2-import-export
========================

Extension for the Yii2 framework for importing and exporting Excel data

0.1.0(3y ago)042MITPHP

Since Sep 16Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Xpbl4/yii2-import-export)[ Packagist](https://packagist.org/packages/xpbl4/yii2-import-export)[ Docs](https://github.com/Xpbl4/yii2-import-export)[ RSS](/packages/xpbl4-yii2-import-export/feed)WikiDiscussions master Synced 1mo ago

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

yii2-import-export
==================

[](#yii2-import-export)

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

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist xpbl4/yii2-import-export "*"

```

or add

```
"xpbl4/yii2-import-export": "*"

```

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 `model`:

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

    if ($form->validate()) {
        Contact::deleteAll();
        $reader = new ExcelReader(['model' => 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('Xlsx');
    Yii::$app->response->sendFile($filename, 'contacts.xlsx')->send();
}

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

1328d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b25027522ebc5202b9a37b3760967bf84b7d5a8dd5f80f2780a71a1c23e892b4?d=identicon)[xpbl4](/maintainers/xpbl4)

---

Top Contributors

[![Xpbl4](https://avatars.githubusercontent.com/u/717048?v=4)](https://github.com/Xpbl4 "Xpbl4 (6 commits)")

---

Tags

excelxlsxlsxcsvyii2

### Embed Badge

![Health badge](/badges/xpbl4-yii2-import-export/health.svg)

```
[![Health](https://phpackages.com/badges/xpbl4-yii2-import-export/health.svg)](https://phpackages.com/packages/xpbl4-yii2-import-export)
```

###  Alternatives

[kartik-v/yii2-export

A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)

1623.1M35](/packages/kartik-v-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)[seine/seine

Seine - Write spreadsheets of various formats to a stream

1270.3k](/packages/seine-seine)

PHPackages © 2026

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