Git Product home page Git Product logo

yii1spreadsheet's Introduction

Yii1 Spreadsheet Extensions

Provides very easy Excel-Output for Yii1

  • works with CArrayDataProvider
  • works with CActiveDataProvider
  • provides flexible value formatting with PHP closures (see below)

This extension was built because the extension phpoffice/phpexcel is marked as "archived/abandoned" and there was no Yii1 extension as successor to use the recommended PhpSpreadsheet library.

Tested with Yii1 version 1.1.25

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist ondics/yii1spreadsheet

or add

"ondics/spreadsheet": "*"

to the require section of your composer.json.

Usage

$dataProvider = new CArrayDataProvider([
    [
        'name' => 'some name',
        'price' => '9879',
    ],
    [
        'name' => 'name 2',
        'price' => '79',
    ],
]);
$exporter = new Spreadsheet();
$exporter->dataProvider = $dataProvider;
$exporter->columns = [
    'name',
    [
        'attribute' => 'price',
        'header' => 'Price with VAT',
        'value' => function($model,$key,$index,$x) {
            return $model->price * 1.19;
          },
          'visible' => ($model->price  > 20),
];
$exporter->send('myexcelfile.xlsx');

Application Notes

This yii1 extension is a light backport of https://github.com/yii2tech/spreadsheet to Yii1. Some Yii2 base classes and features are required and thus provided with this extensions and can be used during Excel export, e.g.

  • In colums a closure can be used as value. This closue differs from the closure in Yii1. See the example above how to use this closure.
  • The columns array is backported from Yii2 so see Yii2 docs for information

The send method cannot not use xsendfile to send a file directyle to the browser but has go over memory. This may affect very large Excel exports.

Credits

Thanks to https://patreon.com/klimov_paul and yii2tech which provide https://github.com/yii2tech/spreadsheet

Author

[email protected]

(C) 2022, Ondics GmbH

yii1spreadsheet's People

Contributors

ondics avatar

Stargazers

 avatar  avatar

Watchers

 avatar

yii1spreadsheet's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.