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

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

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

Extension for the Yii2 framework for importing Excel data

v1.0.0(2y ago)010BSD-3-ClausePHP

Since Aug 29Pushed 1y ago1 watchersCompare

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

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

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

[](#yii2-import)

Extension for the Yii2 framework for importing 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 "*"

```

or add

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

```

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

Usage
-----

[](#usage)

Implement the `ImportInterface`:

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

    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;
	    ...
    }

}

```

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;
}

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Unknown

Total

1

Last Release

988d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

excelxlsxlsxcsvyii2

### Embed Badge

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

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

###  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)
