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

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

blacksesion/yii2-import
=======================

Simple import module for yii2 framework, updated for php &gt;= 7.2

v1.1.1(11mo ago)06BSD-3-ClausePHPPHP &gt;=7.2

Since Mar 10Pushed 11mo agoCompare

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

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

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

[](#yii2-import)

Updated module which uses PHPOffice / PhpSpreadsheet

Yii2-import is an extension for Yii Framework. It helps you transfer file into models. Currently support Excel format only. But it's easily to extend to support your file.

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

[](#installation)

You can use composer to install this extension by:

- run

```
$ php composer.phar require blacksesion/yii2-import "*"

```

- or add

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

```

to your composer.json and then execute 'composer update'.

Usage
-----

[](#usage)

Assume there is a model class

```
class Post extends Model
{
	const STATUS_NEW = 0;
	const STATUS_APPROVED = 1;

	public $title;
	public $status;
	public $content;

	public static function getStatusList()
	{
		return [
			self::STATUS_NEW = 'New',
			self::STATUS_APPROVED = 'Approved',
		];
	}
}
```

And the form and view as below.

```
class ImportForm extends Model
{
	public $file;

	public function rules()
	{
		return [
			['file', 'file', 'skipOnEmpty' => false, 'extensions' => 'xlsx'],
		];
	}
}
```

```
