Download the PHP package iteracode/excel without Composer

On this page you can find all versions of the php package iteracode/excel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package excel

Iteracode/Excel plugin for CakePHP

The plugin is based on the work of [dakota] (https://github.com/dakota/CakeExcel) and uses PHPExcel for the excel-related functionality.

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

add

"repositories": [
         {
            "type": "vcs",
            "url": "https://github.com/Iteracode/excel"
        }
    ] 

to your composer.json because this package is not on packagist. Then in your console:

should fetch the plugin.

Load the Plugin in your bootstrap.php as ususal:

RequestHandler Component is configured by the Plugin's bootstrap file. If not you could do this this in your controller's initialize method, e.g.:

Be careful: RequestHandlerComponent is already loaded in your AppController by default. Adapt the settings to your needs.

You need to set up parsing for the xlsx extension. Add the following to your config/routes.php file before any route or scope definition:

or you can add within a scope:

(Setting this in the plugin's config/routes.php file is currently broken. So you do have to provide the code in the application's config/routes.php file)

You further have to provide a layout for the generated Excel-Files. Add a folder xlsx in src/Template/Layout/ subdirectory and within that folder a file named default.ctp with this minimum content:

You can create Excel Workbooks from views. This works like in dakotas plugin. Look there for docs. Additions:

1. ExcelHelper

Has a Method 'addworksheet' which takes a ResultSet, a Entity, a Collection of Entities or an Array of Data and creates a worksheet from the data. Properties of the Entities, or the keys of the first record in the array are set as column-headers in first row of the generated worksheet. Be careful if you use non-standard column-types. The Helper actually works only with strings, numbers and dates.

Register xlsx-Extension in config/routes.php file before the routes that should be affected:

Example (assumed you have an article model and controller with the usual index-action)

Include the helper in ArticlesController:

add a Folder 'xlsx' in Template/Articles and create the file 'index.ctp' in this Folder. Include this snippet of code to get an excel-file with a single worksheet called 'Articles':

create the link to generate the file somewhere in your app:

done.

2. ImportComponent

Takes a excel workbook, extracts a single worksheet with data (e.g. generated with the helper) and generates an array with data ready for building entities. First row must contain names of properties/database columns.

Include the Import-Component in the controller:

 public function initialize()
 {
    parent::initialize();
    $this->loadComponent('Iteracode/Excel.Import');
 }    

than you can use the method

 prepareEntityData($file = null, array $options = [])

E.g. if you've uploaded a file:

 move_uploaded_file($this->gerRequest()->getData('file.tmp_name'), TMP . DS . $this->getRequest()->getData('file.name'));
 $data = $this->Import->prepareEntityData(TMP . $this->getRequest()->getData('file.name'));

and you'll get an array with data like you would get from the form-helper. You then can generate and save entities in the Controller:

 $entities = $table->newEntities($data);
 foreach ($entities as $entity) {
       $table->save($entity, ['checkExisting' => false])
 }

if your table is not empty and you don't want to replace records in the database, set 'append'=>true in the $options array:

$data = $this->Import->prepareEntityData($file, ['append'=> true]);

If there are more than one worksheets in the file you can supply the name or index of the Worksheet to use in the $options array, e.g.:

$data = $this->Import->prepareEntityData($file, ['worksheet'=> 0]);

or

$data = $this->Import->prepareEntityData($file, ['worksheet'=> 'Articles']);

All versions of excel with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
cakephp/plugin-installer Version *
cakephp/cakephp Version ~3.0
phpoffice/phpexcel Version 1.8.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package iteracode/excel contains the following files

Loading the files please wait ....