kartik-v / yii2-export

A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)
http://demos.krajee.com/export
Other
165 stars 126 forks source link
excel export grid html pdf php spreadsheet yii2

Krajee Logo
yii2-export
Donate       kartikv

[![Stable Version](https://poser.pugx.org/kartik-v/yii2-export/v/stable)](https://packagist.org/packages/kartik-v/yii2-export) [![Unstable Version](https://poser.pugx.org/kartik-v/yii2-export/v/unstable)](https://packagist.org/packages/kartik-v/yii2-export) [![License](https://poser.pugx.org/kartik-v/yii2-export/license)](https://packagist.org/packages/kartik-v/yii2-export) [![Total Downloads](https://poser.pugx.org/kartik-v/yii2-export/downloads)](https://packagist.org/packages/kartik-v/yii2-export) [![Monthly Downloads](https://poser.pugx.org/kartik-v/yii2-export/d/monthly)](https://packagist.org/packages/kartik-v/yii2-export) [![Daily Downloads](https://poser.pugx.org/kartik-v/yii2-export/d/daily)](https://packagist.org/packages/kartik-v/yii2-export)

A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.) using the PhpSpreadsheet library. The widget allows you to configure the dataProvider, columns just like a yii\grid\GridView. However, it just displays the export actions in form of a ButtonDropdown menu, for embedding into any of your GridView or other components.

In addition, with release v1.2.0, the extension also displays a handy grid columns selector for controlling the columns for export. The features available with the column selector are:

The extension offers configurable user interfaces for advanced cases using view templates.

Demo

You can see detailed documentation and demonstration on usage of the extension.

Release Changes

NOTE: Refer the CHANGE LOG for details on changes to various releases.

Installation

The preferred way to install this extension is through composer.

Note: Read this web tip /wiki on setting the minimum-stability settings for your application's composer.json.

Pre-requisites

Install the necessary pre-requisite (Krajee Dropdown Extension) based on your bootstrap version:

For example if you are using the Bootstrap v5.x add the following to the require section of your composer.json file:

"kartik-v/yii2-bootstrap5-dropdown": "@dev"

Install

Either run:

$ php composer.phar require kartik-v/yii2-export "@dev"

or add

"kartik-v/yii2-export": "@dev"

to the require section of your composer.json file.

Note: you must run composer update to have the latest stable dependencies like kartik-v/yii2-krajee-base

Pre-requisites

The yii2-export extension is dependent on yii2-grid extension module. In order to start using yii2-export, you need to ensure setup of the gridview module in your application modules configuration file. For example:

'modules' => [
    'gridview' => [
        'class' => 'kartik\grid\Module',
        // other module settings
    ]
]

Usage

ExportMenu

use kartik\export\ExportMenu;
$gridColumns = [
    ['class' => 'yii\grid\SerialColumn'],
    'id',
    'name',
    'color',
    'publish_date',
    'status',
    ['class' => 'yii\grid\ActionColumn'],
];

// Renders a export dropdown menu
echo ExportMenu::widget([
    'dataProvider' => $dataProvider,
    'columns' => $gridColumns,
    'clearBuffers' => true, //optional
]);

// You can choose to render your own GridView separately
echo \kartik\grid\GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => $gridColumns
]);

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

License

yii2-export is released under the BSD-3-Clause License. See the bundled LICENSE.md for details.