update 1.0.8.0
Commits for version update
This commit is contained in:
126
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/Cache.php
vendored
Normal file
126
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/Cache.php
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php namespace Maatwebsite\Excel\Classes;
|
||||
|
||||
use PHPExcel_Settings;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use PHPExcel_CachedObjectStorageFactory;
|
||||
|
||||
class Cache {
|
||||
|
||||
/**
|
||||
* PHPExcel cache class
|
||||
* @var string
|
||||
*/
|
||||
protected $class = 'PHPExcel_CachedObjectStorageFactory';
|
||||
|
||||
/**
|
||||
* Available caching drivers
|
||||
* @var array
|
||||
*/
|
||||
protected $available = array(
|
||||
'memory' => 'cache_in_memory',
|
||||
'gzip' => 'cache_in_memory_gzip',
|
||||
'serialized' => 'cache_in_memory_serialized',
|
||||
'igbinary' => 'cache_igbinary',
|
||||
'discISAM' => 'cache_to_discISAM',
|
||||
'apc' => 'cache_to_apc',
|
||||
'memcache' => 'cache_to_memcache',
|
||||
'temp' => 'cache_to_phpTemp',
|
||||
'wincache' => 'cache_to_wincache',
|
||||
'sqlite' => 'cache_to_sqlite',
|
||||
'sqlite3' => 'cache_to_sqlite3'
|
||||
);
|
||||
|
||||
/**
|
||||
* The name of the config file
|
||||
* @var string
|
||||
*/
|
||||
private $configName = 'excel.cache';
|
||||
|
||||
/**
|
||||
* Cache constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Get driver and settings from the config
|
||||
$this->driver = Config::get($this->configName . '.driver', 'memory');
|
||||
$this->settings = Config::get($this->configName . '.settings', array());
|
||||
|
||||
// Init if caching is enabled
|
||||
if ($this->isEnabled())
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the cache
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
// Find the cache driver
|
||||
$this->findDriver();
|
||||
|
||||
// Set the storage driver
|
||||
PHPExcel_Settings::setCacheStorageMethod($this->method, $this->settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the right driver
|
||||
* @return void
|
||||
*/
|
||||
public function findDriver()
|
||||
{
|
||||
$property = $this->detect();
|
||||
$this->method = constant($this->class . '::' . $property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect the caching driver
|
||||
* @return string $driver
|
||||
*/
|
||||
protected function detect()
|
||||
{
|
||||
// Add additional settings
|
||||
$this->addAdditionalSettings();
|
||||
|
||||
// return the driver
|
||||
return isset($this->available[$this->driver]) ? $this->available[$this->driver] : reset($this->available);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add additional settings for the current driver
|
||||
* @return void
|
||||
*/
|
||||
protected function addAdditionalSettings()
|
||||
{
|
||||
switch ($this->driver)
|
||||
{
|
||||
case 'memcache':
|
||||
|
||||
// Add extra memcache settings
|
||||
$this->settings = array_merge($this->settings, array(
|
||||
'memcacheServer' => Config::get($this->configName . '.memcache.host', 'localhost'),
|
||||
'memcachePort' => Config::get($this->configName . '.memcache.port', 11211)
|
||||
));
|
||||
|
||||
break;
|
||||
|
||||
case 'discISAM':
|
||||
|
||||
// Add dir
|
||||
$this->settings = array_merge($this->settings, array(
|
||||
'dir' => Config::get($this->configName . '.dir', storage_path('cache')),
|
||||
));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if caching is enabled
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
return Config::get($this->configName . '.enable', true) ? true : false;
|
||||
}
|
||||
}
|
274
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/FormatIdentifier.php
vendored
Normal file
274
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/FormatIdentifier.php
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
<?php namespace Maatwebsite\Excel\Classes;
|
||||
|
||||
use PHPExcel_IOFactory;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
class FormatIdentifier {
|
||||
|
||||
/**
|
||||
* Available formats
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $formats = array(
|
||||
'Excel2007',
|
||||
'Excel5',
|
||||
'Excel2003XML',
|
||||
'OOCalc',
|
||||
'SYLK',
|
||||
'Gnumeric',
|
||||
'CSV',
|
||||
'HTML',
|
||||
'PDF'
|
||||
);
|
||||
|
||||
/**
|
||||
* Construct new format identifier
|
||||
* @param Filesystem $filesystem
|
||||
*/
|
||||
public function __construct(Filesystem $filesystem)
|
||||
{
|
||||
$this->filesystem = $filesystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file format by file
|
||||
* @param $file
|
||||
* @throws LaravelExcelException
|
||||
* @return string $format
|
||||
*/
|
||||
public function getFormatByFile($file)
|
||||
{
|
||||
// get the file extension
|
||||
$ext = $this->getExtension($file);
|
||||
|
||||
// get the file format
|
||||
$format = $this->getFormatByExtension($ext);
|
||||
|
||||
// Check if the file can be read
|
||||
if ($this->canRead($format, $file))
|
||||
return $format;
|
||||
|
||||
// Do a last try to init the file with all available readers
|
||||
return $this->lastResort($file, $format, $ext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify file format
|
||||
* @param $ext
|
||||
* @return string $format
|
||||
*/
|
||||
public function getFormatByExtension($ext)
|
||||
{
|
||||
switch ($ext)
|
||||
{
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Excel 2007
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'xlsx':
|
||||
case 'xlsm':
|
||||
case 'xltx':
|
||||
case 'xltm':
|
||||
return 'Excel2007';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Excel5
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'xls':
|
||||
case 'xlt':
|
||||
return 'Excel5';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| OOCalc
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'ods':
|
||||
case 'ots':
|
||||
return 'OOCalc';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SYLK
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'slk':
|
||||
return 'SYLK';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Excel2003XML
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'xml':
|
||||
return 'Excel2003XML';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Gnumeric
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'gnumeric':
|
||||
return 'Gnumeric';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTML
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'htm':
|
||||
case 'html':
|
||||
return 'HTML';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CSV
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'csv':
|
||||
case 'txt':
|
||||
return 'CSV';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PDF
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'pdf':
|
||||
return 'PDF';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content type by file format
|
||||
* @param string $format
|
||||
* @return string $contentType
|
||||
*/
|
||||
public function getContentTypeByFormat($format)
|
||||
{
|
||||
switch ($format)
|
||||
{
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Excel 2007
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'Excel2007':
|
||||
return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Excel5
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'Excel5':
|
||||
return 'application/vnd.ms-excel; charset=UTF-8';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTML
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'HTML':
|
||||
return 'HTML';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CSV
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'CSV':
|
||||
return 'application/csv; charset=UTF-8';
|
||||
break;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PDF
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
case 'PDF':
|
||||
return'application/pdf; charset=UTF-8';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try every reader we have
|
||||
* @param $file
|
||||
* @param bool $wrongFormat
|
||||
* @param string $ext
|
||||
* @throws LaravelExcelException
|
||||
* @return string $format
|
||||
*/
|
||||
protected function lastResort($file, $wrongFormat = false, $ext = 'xls')
|
||||
{
|
||||
// Loop through all available formats
|
||||
foreach ($this->formats as $format)
|
||||
{
|
||||
// Check if the file could be read
|
||||
if ($wrongFormat != $format && $this->canRead($format, $file))
|
||||
return $format;
|
||||
}
|
||||
|
||||
// Give up searching and throw an exception
|
||||
throw new LaravelExcelException('[ERROR] Reader could not identify file format for file [' . $file . '] with extension [' . $ext . ']');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we can read the file
|
||||
* @param $format
|
||||
* @param $file
|
||||
* @return boolean
|
||||
*/
|
||||
protected function canRead($format, $file)
|
||||
{
|
||||
if ($format)
|
||||
{
|
||||
$reader = $this->initReader($format);
|
||||
|
||||
return $reader && $reader->canRead($file);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the reader based on the format
|
||||
* @param string $format
|
||||
* @return \PHPExcel_Reader_IReader
|
||||
*/
|
||||
protected function initReader($format)
|
||||
{
|
||||
return PHPExcel_IOFactory::createReader($format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file extension
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
protected function getExtension($file)
|
||||
{
|
||||
return strtolower($this->filesystem->extension($file));
|
||||
}
|
||||
}
|
1273
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/LaravelExcelWorksheet.php
vendored
Normal file
1273
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/LaravelExcelWorksheet.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
124
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/PHPExcel.php
vendored
Normal file
124
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Classes/PHPExcel.php
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php namespace Maatwebsite\Excel\Classes;
|
||||
|
||||
use PHPExcel as PHPOffice_PHPExcel;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
/**
|
||||
*
|
||||
* Laravel wrapper for PHPExcel
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @copyright Original Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class PHPExcel extends PHPOffice_PHPExcel {
|
||||
|
||||
/**
|
||||
* Allowed autofill properties
|
||||
* @var array
|
||||
*/
|
||||
public $allowedProperties = array(
|
||||
'creator',
|
||||
'lastModifiedBy',
|
||||
'description',
|
||||
'subject',
|
||||
'keywords',
|
||||
'category',
|
||||
'manager',
|
||||
'company'
|
||||
);
|
||||
|
||||
/**
|
||||
* Create sheet and add it to this workbook
|
||||
*
|
||||
* @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)
|
||||
* @param bool|string $title
|
||||
* @throws \PHPExcel_Exception
|
||||
* @return LaravelExcelWorksheet
|
||||
*/
|
||||
public function createSheet($iSheetIndex = null, $title = false)
|
||||
{
|
||||
// Init new Laravel Excel worksheet
|
||||
$newSheet = new LaravelExcelWorksheet($this, $title);
|
||||
|
||||
// Add the sheet
|
||||
$this->addSheet($newSheet, $iSheetIndex);
|
||||
|
||||
// Return the sheet
|
||||
return $newSheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user change change the workbook property
|
||||
* @param string $method
|
||||
* @return boolean
|
||||
*/
|
||||
public function isChangeableProperty($method)
|
||||
{
|
||||
$name = lcfirst(str_replace('set', '', $method));
|
||||
|
||||
return in_array($name, $this->getAllowedProperties()) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default properties
|
||||
* @param array $custom
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultProperties($custom = [])
|
||||
{
|
||||
// Get the properties
|
||||
$properties = $this->getProperties();
|
||||
|
||||
// Get fillable properties
|
||||
foreach ($this->getAllowedProperties() as $prop)
|
||||
{
|
||||
// Get the method
|
||||
$method = 'set' . ucfirst($prop);
|
||||
|
||||
// get the value
|
||||
$value = in_array($prop, array_keys($custom)) ? $custom[$prop] : Config::get('excel.properties.' . $prop, null);
|
||||
|
||||
// set the property
|
||||
call_user_func_array(array($properties, $method), array($value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* load info from parent obj
|
||||
* @param \PHPExcel $object
|
||||
* @return $this
|
||||
*/
|
||||
function cloneParent(\PHPExcel $object)
|
||||
{
|
||||
// Init new reflection object
|
||||
$class = new \ReflectionClass(get_class($object));
|
||||
|
||||
// Loop through all properties
|
||||
foreach($class->getProperties() as $property)
|
||||
{
|
||||
// Make the property public
|
||||
$property->setAccessible(true);
|
||||
|
||||
// Set the found value to this sheet
|
||||
$property->setValue(
|
||||
$this,
|
||||
$property->getValue($object)
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all allowed properties
|
||||
* @return array
|
||||
*/
|
||||
public function getAllowedProperties()
|
||||
{
|
||||
return $this->allowedProperties;
|
||||
}
|
||||
}
|
68
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/CellCollection.php
vendored
Normal file
68
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/CellCollection.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php namespace Maatwebsite\Excel\Collections;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel CellCollection
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class CellCollection extends ExcelCollection {
|
||||
|
||||
/**
|
||||
* Create a new collection.
|
||||
* @param array $items
|
||||
* @return \Maatwebsite\Excel\Collections\CellCollection
|
||||
*/
|
||||
public function __construct(array $items = array())
|
||||
{
|
||||
$this->setItems($items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the items
|
||||
* @param array $items
|
||||
* @return void
|
||||
*/
|
||||
public function setItems($items)
|
||||
{
|
||||
foreach ($items as $name => $value)
|
||||
{
|
||||
$value = !empty($value) || is_numeric($value) ? $value : null;
|
||||
|
||||
if ($name)
|
||||
{
|
||||
$this->put($name, $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->push($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically get values
|
||||
* @param string $key
|
||||
* @return string
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
if ($this->has($key))
|
||||
return $this->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an attribute exists on the model.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return $this->has($key);
|
||||
}
|
||||
}
|
41
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/ExcelCollection.php
vendored
Normal file
41
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/ExcelCollection.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php namespace Maatwebsite\Excel\Collections;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel ExcelCollection
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class ExcelCollection extends Collection {
|
||||
|
||||
/**
|
||||
* Sheet title
|
||||
* @var [type]
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* Get the title
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title
|
||||
* @param $title
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
}
|
16
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/RowCollection.php
vendored
Normal file
16
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/RowCollection.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php namespace Maatwebsite\Excel\Collections;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel RowCollection
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class RowCollection extends ExcelCollection {
|
||||
|
||||
}
|
16
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/SheetCollection.php
vendored
Normal file
16
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Collections/SheetCollection.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php namespace Maatwebsite\Excel\Collections;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel SheetCollection
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class SheetCollection extends ExcelCollection {
|
||||
|
||||
}
|
278
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Excel.php
vendored
Normal file
278
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Excel.php
vendored
Normal file
@@ -0,0 +1,278 @@
|
||||
<?php namespace Maatwebsite\Excel;
|
||||
|
||||
use Closure;
|
||||
use Maatwebsite\Excel\Readers\Batch;
|
||||
use Maatwebsite\Excel\Classes\PHPExcel;
|
||||
use Maatwebsite\Excel\Readers\LaravelExcelReader;
|
||||
use Maatwebsite\Excel\Writers\LaravelExcelWriter;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Laravel wrapper for PHPExcel
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class Excel {
|
||||
|
||||
/**
|
||||
* Filter
|
||||
* @var array
|
||||
*/
|
||||
protected $filters = array(
|
||||
'registered' => array(),
|
||||
'enabled' => array()
|
||||
);
|
||||
|
||||
/**
|
||||
* Excel object
|
||||
* @var PHPExcel
|
||||
*/
|
||||
protected $excel;
|
||||
|
||||
/**
|
||||
* Reader object
|
||||
* @var LaravelExcelReader
|
||||
*/
|
||||
protected $reader;
|
||||
|
||||
/**
|
||||
* Writer object
|
||||
* @var LaravelExcelWriter
|
||||
*/
|
||||
protected $writer;
|
||||
|
||||
/**
|
||||
* Construct Excel
|
||||
* @param PHPExcel $excel
|
||||
* @param LaravelExcelReader $reader
|
||||
* @param LaravelExcelWriter $writer
|
||||
*/
|
||||
public function __construct(PHPExcel $excel, LaravelExcelReader $reader, LaravelExcelWriter $writer)
|
||||
{
|
||||
// Set Excel dependencies
|
||||
$this->excel = $excel;
|
||||
$this->reader = $reader;
|
||||
$this->writer = $writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new file
|
||||
* @param $filename
|
||||
* @param callable|null $callback
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function create($filename, $callback = null)
|
||||
{
|
||||
// Writer instance
|
||||
$writer = clone $this->writer;
|
||||
|
||||
// Disconnect worksheets to prevent unnecessary ones
|
||||
$this->excel->disconnectWorksheets();
|
||||
|
||||
// Inject our excel object
|
||||
$writer->injectExcel($this->excel);
|
||||
|
||||
// Set the filename and title
|
||||
$writer->setFileName($filename);
|
||||
$writer->setTitle($filename);
|
||||
|
||||
// Do the callback
|
||||
if ($callback instanceof Closure)
|
||||
call_user_func($callback, $writer);
|
||||
|
||||
// Return the writer object
|
||||
return $writer;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Load an existing file
|
||||
*
|
||||
* @param string $file The file we want to load
|
||||
* @param callback|null $callback
|
||||
* @param string|null $encoding
|
||||
* @param bool $noBasePath
|
||||
* @return LaravelExcelReader
|
||||
*/
|
||||
public function load($file, $callback = null, $encoding = null, $noBasePath = false, $callbackConfigReader = null)
|
||||
{
|
||||
// Reader instance
|
||||
$reader = clone $this->reader;
|
||||
|
||||
// Inject excel object
|
||||
$reader->injectExcel($this->excel);
|
||||
|
||||
// Enable filters
|
||||
$reader->setFilters($this->filters);
|
||||
|
||||
// Set the encoding
|
||||
$encoding = is_string($callback) ? $callback : $encoding;
|
||||
|
||||
// Start loading
|
||||
$reader->load($file, $encoding, $noBasePath, $callbackConfigReader);
|
||||
|
||||
// Do the callback
|
||||
if ($callback instanceof Closure)
|
||||
call_user_func($callback, $reader);
|
||||
|
||||
// Return the reader object
|
||||
return $reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set select sheets
|
||||
* @param $sheets
|
||||
* @return LaravelExcelReader
|
||||
*/
|
||||
public function selectSheets($sheets = array())
|
||||
{
|
||||
$sheets = is_array($sheets) ? $sheets : func_get_args();
|
||||
$this->reader->setSelectedSheets($sheets);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select sheets by index
|
||||
* @param array $sheets
|
||||
* @return $this
|
||||
*/
|
||||
public function selectSheetsByIndex($sheets = array())
|
||||
{
|
||||
$sheets = is_array($sheets) ? $sheets : func_get_args();
|
||||
$this->reader->setSelectedSheetIndices($sheets);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch import
|
||||
* @param $files
|
||||
* @param callback $callback
|
||||
* @return PHPExcel
|
||||
*/
|
||||
public function batch($files, Closure $callback)
|
||||
{
|
||||
$batch = new Batch;
|
||||
|
||||
return $batch->start($this, $files, $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new file and share a view
|
||||
* @param string $view
|
||||
* @param array $data
|
||||
* @param array $mergeData
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function shareView($view, $data = array(), $mergeData = array())
|
||||
{
|
||||
return $this->create($view)->shareView($view, $data, $mergeData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new file and load a view
|
||||
* @param string $view
|
||||
* @param array $data
|
||||
* @param array $mergeData
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function loadView($view, $data = array(), $mergeData = array())
|
||||
{
|
||||
return $this->shareView($view, $data, $mergeData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set filters
|
||||
* @param array $filters
|
||||
* @return Excel
|
||||
*/
|
||||
public function registerFilters($filters = array())
|
||||
{
|
||||
// If enabled array key exists
|
||||
if(array_key_exists('enabled', $filters))
|
||||
{
|
||||
// Set registered array
|
||||
$registered = $filters['registered'];
|
||||
|
||||
// Filter on enabled
|
||||
$this->filter($filters['enabled']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$registered = $filters;
|
||||
}
|
||||
|
||||
// Register the filters
|
||||
$this->filters['registered'] = !empty($this->filters['registered']) ? array_merge($this->filters['registered'], $registered) : $registered;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable certain filters
|
||||
* @param string|array $filter
|
||||
* @param bool|false|string $class
|
||||
* @return Excel
|
||||
*/
|
||||
public function filter($filter, $class = false)
|
||||
{
|
||||
// Add multiple filters
|
||||
if(is_array($filter))
|
||||
{
|
||||
$this->filters['enabled'] = !empty($this->filters['enabled']) ? array_merge($this->filters['enabled'], $filter) : $filter;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add single filter
|
||||
$this->filters['enabled'][] = $filter;
|
||||
|
||||
// Overrule filter class for this request
|
||||
if($class)
|
||||
$this->filters['registered'][$filter] = $class;
|
||||
}
|
||||
|
||||
// Remove duplicates
|
||||
$this->filters['enabled'] = array_unique($this->filters['enabled']);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get register, enabled (or both) filters
|
||||
* @param string|boolean $key [description]
|
||||
* @return array
|
||||
*/
|
||||
public function getFilters($key = false)
|
||||
{
|
||||
return $key ? $this->filters[$key] : $this->filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call methods
|
||||
* @throws LaravelExcelException
|
||||
*/
|
||||
public function __call($method, $params)
|
||||
{
|
||||
// If the dynamic call starts with "with", add the var to the data array
|
||||
if (method_exists($this->excel, $method))
|
||||
{
|
||||
// Call the method from the excel object with the given params
|
||||
return call_user_func_array(array($this->excel, $method), $params);
|
||||
}
|
||||
|
||||
// If reader method exists, call that one
|
||||
if (method_exists($this->reader, $method))
|
||||
{
|
||||
// Call the method from the reader object with the given params
|
||||
return call_user_func_array(array($this->reader, $method), $params);
|
||||
}
|
||||
|
||||
throw new LaravelExcelException('Laravel Excel method [' . $method . '] does not exist');
|
||||
}
|
||||
}
|
247
vendor/maatwebsite/excel/src/Maatwebsite/Excel/ExcelServiceProvider.php
vendored
Normal file
247
vendor/maatwebsite/excel/src/Maatwebsite/Excel/ExcelServiceProvider.php
vendored
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php namespace Maatwebsite\Excel;
|
||||
|
||||
use PHPExcel_Settings;
|
||||
use PHPExcel_Shared_Font;
|
||||
use Maatwebsite\Excel\Readers\Html;
|
||||
use Maatwebsite\Excel\Classes\Cache;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Maatwebsite\Excel\Classes\PHPExcel;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Maatwebsite\Excel\Parsers\CssParser;
|
||||
use Maatwebsite\Excel\Parsers\ViewParser;
|
||||
use Maatwebsite\Excel\Classes\FormatIdentifier;
|
||||
use Maatwebsite\Excel\Readers\LaravelExcelReader;
|
||||
use Maatwebsite\Excel\Writers\LaravelExcelWriter;
|
||||
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Excel ServiceProvider
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class ExcelServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = false;
|
||||
|
||||
/**
|
||||
* Bootstrap the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function boot()
|
||||
{
|
||||
$this->publishes([
|
||||
__DIR__ . '/../../config/excel.php' => config_path('excel.php'),
|
||||
]);
|
||||
|
||||
$this->mergeConfigFrom(
|
||||
__DIR__ . '/../../config/excel.php', 'excel'
|
||||
);
|
||||
|
||||
//Set the autosizing settings
|
||||
$this->setAutoSizingSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->bindClasses();
|
||||
$this->bindCssParser();
|
||||
$this->bindReaders();
|
||||
$this->bindParsers();
|
||||
$this->bindPHPExcelClass();
|
||||
$this->bindWriters();
|
||||
$this->bindExcel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind PHPExcel classes
|
||||
* @return void
|
||||
*/
|
||||
protected function bindPHPExcelClass()
|
||||
{
|
||||
// Set object
|
||||
$me = $this;
|
||||
|
||||
// Bind the PHPExcel class
|
||||
$this->app['phpexcel'] = $this->app->share(function () use ($me)
|
||||
{
|
||||
// Set locale
|
||||
$me->setLocale();
|
||||
|
||||
// Set the caching settings
|
||||
$me->setCacheSettings();
|
||||
|
||||
// Init phpExcel
|
||||
$excel = new PHPExcel();
|
||||
$excel->setDefaultProperties();
|
||||
return $excel;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind the css parser
|
||||
*/
|
||||
protected function bindCssParser()
|
||||
{
|
||||
// Bind css parser
|
||||
$this->app['excel.parsers.css'] = $this->app->share(function ()
|
||||
{
|
||||
return new CssParser(
|
||||
new CssToInlineStyles()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind writers
|
||||
* @return void
|
||||
*/
|
||||
protected function bindReaders()
|
||||
{
|
||||
// Bind the laravel excel reader
|
||||
$this->app['excel.reader'] = $this->app->share(function ($app)
|
||||
{
|
||||
return new LaravelExcelReader(
|
||||
$app['files'],
|
||||
$app['excel.identifier'],
|
||||
$app['Illuminate\Contracts\Bus\Dispatcher']
|
||||
);
|
||||
});
|
||||
|
||||
// Bind the html reader class
|
||||
$this->app['excel.readers.html'] = $this->app->share(function ($app)
|
||||
{
|
||||
return new Html(
|
||||
$app['excel.parsers.css']
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind writers
|
||||
* @return void
|
||||
*/
|
||||
protected function bindParsers()
|
||||
{
|
||||
// Bind the view parser
|
||||
$this->app['excel.parsers.view'] = $this->app->share(function ($app)
|
||||
{
|
||||
return new ViewParser(
|
||||
$app['excel.readers.html']
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind writers
|
||||
* @return void
|
||||
*/
|
||||
protected function bindWriters()
|
||||
{
|
||||
// Bind the excel writer
|
||||
$this->app['excel.writer'] = $this->app->share(function ($app)
|
||||
{
|
||||
return new LaravelExcelWriter(
|
||||
$app->make(Response::class),
|
||||
$app['files'],
|
||||
$app['excel.identifier']
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind Excel class
|
||||
* @return void
|
||||
*/
|
||||
protected function bindExcel()
|
||||
{
|
||||
// Bind the Excel class and inject its dependencies
|
||||
$this->app['excel'] = $this->app->share(function ($app)
|
||||
{
|
||||
$excel = new Excel(
|
||||
$app['phpexcel'],
|
||||
$app['excel.reader'],
|
||||
$app['excel.writer'],
|
||||
$app['excel.parsers.view']
|
||||
);
|
||||
|
||||
$excel->registerFilters($app['config']->get('excel.filters', array()));
|
||||
|
||||
return $excel;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind other classes
|
||||
* @return void
|
||||
*/
|
||||
protected function bindClasses()
|
||||
{
|
||||
// Bind the format identifier
|
||||
$this->app['excel.identifier'] = $this->app->share(function ($app)
|
||||
{
|
||||
return new FormatIdentifier($app['files']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cache settings
|
||||
* @return Cache
|
||||
*/
|
||||
public function setCacheSettings()
|
||||
{
|
||||
return new Cache();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set locale
|
||||
*/
|
||||
public function setLocale()
|
||||
{
|
||||
$locale = Config::get('app.locale', 'en_us');
|
||||
PHPExcel_Settings::setLocale($locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the autosizing settings
|
||||
*/
|
||||
public function setAutoSizingSettings()
|
||||
{
|
||||
$method = Config::get('excel.export.autosize-method', PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX);
|
||||
PHPExcel_Shared_Font::setAutoSizeMethod($method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return array(
|
||||
'excel',
|
||||
'phpexcel',
|
||||
'excel.reader',
|
||||
'excel.readers.html',
|
||||
'excel.parsers.view',
|
||||
'excel.writer'
|
||||
);
|
||||
}
|
||||
}
|
18
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Exceptions/LaravelExcelException.php
vendored
Normal file
18
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Exceptions/LaravelExcelException.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php namespace Maatwebsite\Excel\Exceptions;
|
||||
|
||||
use PHPExcel_Exception;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Exception
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class LaravelExcelException extends PHPExcel_Exception {
|
||||
|
||||
}
|
26
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Facades/Excel.php
vendored
Normal file
26
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Facades/Excel.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php namespace Maatwebsite\Excel\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Facade
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class Excel extends Facade {
|
||||
|
||||
/**
|
||||
* Return facade accessor
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'excel';
|
||||
}
|
||||
}
|
156
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/ExcelFile.php
vendored
Normal file
156
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/ExcelFile.php
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php namespace Maatwebsite\Excel\Files;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
abstract class ExcelFile extends File {
|
||||
|
||||
/**
|
||||
* @var bool|string
|
||||
*/
|
||||
protected $delimiter;
|
||||
|
||||
/**
|
||||
* @var bool|string
|
||||
*/
|
||||
protected $enclosure;
|
||||
|
||||
/**
|
||||
* @var null
|
||||
*/
|
||||
protected $encoding = null;
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
* @param Excel $excel
|
||||
*/
|
||||
public function __construct(Application $app, Excel $excel)
|
||||
{
|
||||
parent::__construct($app, $excel);
|
||||
$this->file = $this->loadFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getFile();
|
||||
|
||||
/**
|
||||
* Get delimiter
|
||||
* @return string
|
||||
*/
|
||||
protected function getDelimiter()
|
||||
{
|
||||
return $this->delimiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enclosure
|
||||
* @return string
|
||||
*/
|
||||
protected function getEnclosure()
|
||||
{
|
||||
return $this->enclosure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filters
|
||||
* @return array
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Start importing
|
||||
*/
|
||||
public function handleImport()
|
||||
{
|
||||
return $this->handle(
|
||||
get_class($this)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the file
|
||||
* @return \Maatwebsite\Excel\Readers\LaravelExcelReader
|
||||
*/
|
||||
public function loadFile()
|
||||
{
|
||||
// Load filters
|
||||
$this->loadFilters();
|
||||
|
||||
// Load base settings
|
||||
$this->loadBaseSettings();
|
||||
|
||||
// Load the file
|
||||
$file = $this->excel->load(
|
||||
$this->getFile(),
|
||||
null,
|
||||
$this->encoding
|
||||
);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the filter
|
||||
* @return void
|
||||
*/
|
||||
protected function loadFilters()
|
||||
{
|
||||
// Register the filters
|
||||
$this->excel->registerFilters(
|
||||
$this->getFilters()
|
||||
);
|
||||
|
||||
// Loop through the filters
|
||||
foreach($this->getFilters() as $filter)
|
||||
{
|
||||
// Enable the filter
|
||||
$this->excel->filter($filter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load base settings
|
||||
*/
|
||||
protected function loadBaseSettings()
|
||||
{
|
||||
$this->loadCSVSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load CSV Settings
|
||||
*/
|
||||
protected function loadCSVSettings()
|
||||
{
|
||||
// Get user provided delimiter
|
||||
$delimiter = $this->getDelimiter();
|
||||
|
||||
// Set it when given
|
||||
if($delimiter)
|
||||
$this->excel->setDelimiter($delimiter);
|
||||
|
||||
// Get user provided enclosure
|
||||
$enclosure = $this->getEnclosure();
|
||||
|
||||
// Set it when given
|
||||
if($enclosure)
|
||||
$this->excel->setEnclosure($enclosure);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call methods
|
||||
* @param string $method
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $params)
|
||||
{
|
||||
return call_user_func_array([$this->file, $method], $params);
|
||||
}
|
||||
}
|
12
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/ExportHandler.php
vendored
Normal file
12
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/ExportHandler.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php namespace Maatwebsite\Excel\Files;
|
||||
|
||||
interface ExportHandler {
|
||||
|
||||
/**
|
||||
* Handle the export
|
||||
* @param $file
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($file);
|
||||
|
||||
}
|
90
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/File.php
vendored
Normal file
90
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/File.php
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php namespace Maatwebsite\Excel\Files;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
abstract class File {
|
||||
|
||||
/**
|
||||
* @var Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* Excel instance
|
||||
* @var Excel
|
||||
*/
|
||||
protected $excel;
|
||||
|
||||
/**
|
||||
* Loaded file
|
||||
* @var \Maatwebsite\Excel\Readers\LaravelExcelReader
|
||||
*/
|
||||
protected $file;
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
* @param Excel $excel
|
||||
*/
|
||||
public function __construct(Application $app, Excel $excel)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->excel = $excel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the import/export of the file
|
||||
* @param $type
|
||||
* @throws LaravelExcelException
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($type)
|
||||
{
|
||||
// Get the handler
|
||||
$handler = $this->getHandler($type);
|
||||
|
||||
// Call the handle method and inject the file
|
||||
return $handler->handle($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get handler
|
||||
* @param $type
|
||||
* @throws LaravelExcelException
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getHandler($type)
|
||||
{
|
||||
return $this->app->make(
|
||||
$this->getHandlerClassName($type)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file instance
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFileInstance()
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the handler class name
|
||||
* @throws LaravelExcelException
|
||||
* @return string
|
||||
*/
|
||||
protected function getHandlerClassName($type)
|
||||
{
|
||||
// Translate the file into a FileHandler
|
||||
$class = get_class($this);
|
||||
$handler = substr_replace($class, $type . 'Handler', strrpos($class, $type));
|
||||
|
||||
// Check if the handler exists
|
||||
if (!class_exists($handler))
|
||||
throw new LaravelExcelException("$type handler [$handler] does not exist.");
|
||||
|
||||
return $handler;
|
||||
}
|
||||
}
|
12
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/ImportHandler.php
vendored
Normal file
12
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/ImportHandler.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php namespace Maatwebsite\Excel\Files;
|
||||
|
||||
interface ImportHandler {
|
||||
|
||||
/**
|
||||
* Handle the import
|
||||
* @param $file
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($file);
|
||||
|
||||
}
|
60
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/NewExcelFile.php
vendored
Normal file
60
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Files/NewExcelFile.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php namespace Maatwebsite\Excel\Files;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
abstract class NewExcelFile extends File {
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
* @param Excel $excel
|
||||
*/
|
||||
public function __construct(Application $app, Excel $excel)
|
||||
{
|
||||
parent::__construct($app, $excel);
|
||||
$this->file = $this->createNewFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getFilename();
|
||||
|
||||
/**
|
||||
* Start importing
|
||||
*/
|
||||
public function handleExport()
|
||||
{
|
||||
return $this->handle(
|
||||
get_class($this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load the file
|
||||
* @return \Maatwebsite\Excel\Readers\LaravelExcelReader
|
||||
*/
|
||||
public function createNewFile()
|
||||
{
|
||||
// Load the file
|
||||
$file = $this->excel->create(
|
||||
$this->getFilename()
|
||||
);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call methods
|
||||
* @param string $method
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $params)
|
||||
{
|
||||
return call_user_func_array([$this->file, $method], $params);
|
||||
}
|
||||
|
||||
}
|
46
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Filters/ChunkReadFilter.php
vendored
Normal file
46
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Filters/ChunkReadFilter.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php namespace Maatwebsite\Excel\Filters;
|
||||
|
||||
use PHPExcel_Reader_IReadFilter;
|
||||
|
||||
class ChunkReadFilter implements PHPExcel_Reader_IReadFilter
|
||||
{
|
||||
/**
|
||||
* Start row
|
||||
* @var integer
|
||||
*/
|
||||
private $_startRow = 0;
|
||||
|
||||
/**
|
||||
* End row
|
||||
* @var integer
|
||||
*/
|
||||
private $_endRow = 0;
|
||||
|
||||
/**
|
||||
* Set the list of rows that we want to read
|
||||
* @param integer $startRow
|
||||
* @param integer $chunkSize
|
||||
* @return void
|
||||
*/
|
||||
public function setRows($startRow, $chunkSize)
|
||||
{
|
||||
$this->_startRow = $startRow;
|
||||
$this->_endRow = $startRow + $chunkSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the cell
|
||||
* @param string $column
|
||||
* @param integer $row
|
||||
* @param string $worksheetName
|
||||
* @return booleaan
|
||||
*/
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
{
|
||||
// Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
|
||||
if (($row == config('excel.import.startRow')) || ($row >= $this->_startRow && $row <= $this->_endRow)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
134
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/CssParser.php
vendored
Normal file
134
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/CssParser.php
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php namespace Maatwebsite\Excel\Parsers;
|
||||
|
||||
use DOMDocument;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel CSS Parser
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class CssParser {
|
||||
|
||||
/**
|
||||
* @var CssToInlineStyles
|
||||
*/
|
||||
protected $cssInliner;
|
||||
|
||||
/**
|
||||
* DOM xml
|
||||
* @var \SimpleXMLElement
|
||||
*/
|
||||
protected $xml;
|
||||
|
||||
/**
|
||||
* Style sheet links
|
||||
* @var array
|
||||
*/
|
||||
protected $links = array();
|
||||
|
||||
/**
|
||||
* Construct the css parser
|
||||
* @param CssToInlineStyles $cssInliner
|
||||
*/
|
||||
public function __construct(CssToInlineStyles $cssInliner)
|
||||
{
|
||||
$this->cssInliner = $cssInliner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the found css to inline styles
|
||||
*/
|
||||
public function transformCssToInlineStyles($html)
|
||||
{
|
||||
// Clean-up html
|
||||
$this->cssInliner->setCleanup(true);
|
||||
|
||||
// Set html
|
||||
$this->cssInliner->setHtml($html);
|
||||
|
||||
// Use inline style blocks
|
||||
$this->cssInliner->setUseInlineStylesBlock(true);
|
||||
|
||||
// Loop through all stylesheets
|
||||
foreach($this->links as $link)
|
||||
{
|
||||
$css = file_get_contents($link);
|
||||
$this->cssInliner->setCSS($css);
|
||||
}
|
||||
|
||||
return $this->cssInliner->convert();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the stylesheets inside the view
|
||||
* @param DOMDocument $dom
|
||||
* @return CssParser
|
||||
*/
|
||||
public function findStyleSheets(DOMDocument $dom)
|
||||
{
|
||||
// Import the dom
|
||||
$this->importDom($dom);
|
||||
|
||||
// Get all stylesheet tags
|
||||
$tags = $this->getStyleSheetTags();
|
||||
|
||||
foreach ($tags as $node)
|
||||
{
|
||||
$this->links[] = $this->getCleanStyleSheetLink($node);
|
||||
}
|
||||
|
||||
// We don't need duplicate css files
|
||||
$this->links = array_unique($this->links);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import the dom
|
||||
* @return SimpleXMLElement
|
||||
*/
|
||||
protected function importDom(DOMDocument $dom)
|
||||
{
|
||||
return $this->xml = simplexml_import_dom($dom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all stylesheet tags
|
||||
* @return array
|
||||
*/
|
||||
protected function getStyleSheetTags()
|
||||
{
|
||||
return $this->xml->xpath('//link[@rel="stylesheet"]');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the clean link to the stylesheet
|
||||
* @param string $node
|
||||
* @return string
|
||||
*/
|
||||
protected function getCleanStyleSheetLink($node)
|
||||
{
|
||||
// Get the link
|
||||
$link = $node->attributes()->href;
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get css from link
|
||||
* @param string $link
|
||||
* @return string|boolean
|
||||
*/
|
||||
protected function getCssFromLink($link)
|
||||
{
|
||||
return file_get_contents($link);
|
||||
}
|
||||
}
|
667
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/ExcelParser.php
vendored
Normal file
667
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/ExcelParser.php
vendored
Normal file
@@ -0,0 +1,667 @@
|
||||
<?php namespace Maatwebsite\Excel\Parsers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use PHPExcel_Cell;
|
||||
use PHPExcel_Exception;
|
||||
use PHPExcel_Shared_Date;
|
||||
use Illuminate\Support\Str;
|
||||
use PHPExcel_Style_NumberFormat;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Maatwebsite\Excel\Collections\RowCollection;
|
||||
use Maatwebsite\Excel\Collections\CellCollection;
|
||||
use Maatwebsite\Excel\Collections\SheetCollection;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Excel Parser
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class ExcelParser {
|
||||
|
||||
/**
|
||||
* If file is parsed
|
||||
* @var boolean
|
||||
*/
|
||||
public $isParsed = false;
|
||||
|
||||
/**
|
||||
* Reader object
|
||||
* @var LaravelExcelReader
|
||||
*/
|
||||
protected $reader;
|
||||
|
||||
/**
|
||||
* Excel object
|
||||
* @var PHPExcel
|
||||
*/
|
||||
protected $excel;
|
||||
|
||||
/**
|
||||
* Worksheet object
|
||||
* @var LaravelExcelWorksheet
|
||||
*/
|
||||
protected $worksheet;
|
||||
|
||||
/**
|
||||
* Row object
|
||||
* @var PHPExcel_Worksheet_Row
|
||||
*/
|
||||
protected $row;
|
||||
|
||||
/**
|
||||
* Cell object
|
||||
* @var PHPExcel_Cell
|
||||
*/
|
||||
protected $cell;
|
||||
|
||||
/**
|
||||
* Indices
|
||||
* @var array
|
||||
*/
|
||||
protected $indices;
|
||||
|
||||
/**
|
||||
* Columns we want to fetch
|
||||
* @var array
|
||||
*/
|
||||
protected $columns = array();
|
||||
|
||||
/**
|
||||
* Row counter
|
||||
* @var integer
|
||||
*/
|
||||
protected $currentRow = 1;
|
||||
|
||||
/**
|
||||
* Default startrow
|
||||
* @var integer
|
||||
*/
|
||||
protected $defaultStartRow = 1;
|
||||
|
||||
/**
|
||||
* Construct excel parser
|
||||
* @param LaravelExcelReader $reader
|
||||
* @return \Maatwebsite\Excel\Parsers\ExcelParser
|
||||
*/
|
||||
public function __construct($reader)
|
||||
{
|
||||
$this->reader = $reader;
|
||||
$this->excel = $reader->excel;
|
||||
|
||||
$this->defaultStartRow = $this->currentRow = Config::get('excel.import.startRow', 1);
|
||||
|
||||
// Reset
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the file
|
||||
* @param array $columns
|
||||
* @return SheetCollection
|
||||
*/
|
||||
public function parseFile($columns = array())
|
||||
{
|
||||
// Init new sheet collection
|
||||
$workbook = new SheetCollection();
|
||||
|
||||
// Set the selected columns
|
||||
$this->setSelectedColumns($columns);
|
||||
|
||||
// If not parsed yet
|
||||
if ( !$this->isParsed )
|
||||
{
|
||||
// Set worksheet count
|
||||
$this->w = 0;
|
||||
|
||||
// Get selected sheets
|
||||
$iterator = $this->excel->getWorksheetIterator();
|
||||
|
||||
// Loop through the worksheets
|
||||
foreach ($iterator as $this->worksheet)
|
||||
{
|
||||
// Check if the sheet might have been selected by it's index
|
||||
if ( $this->reader->isSelectedByIndex($iterator->key()) )
|
||||
{
|
||||
// Parse the worksheet
|
||||
$worksheet = $this->parseWorksheet();
|
||||
|
||||
// If multiple sheets
|
||||
if ( $this->parseAsMultiple() )
|
||||
{
|
||||
// Push every sheet
|
||||
$workbook->push($worksheet);
|
||||
$workbook->setTitle($this->excel->getProperties()->getTitle());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore the sheet collection
|
||||
$workbook = $worksheet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->w++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->isParsed = true;
|
||||
|
||||
// Return itself
|
||||
return $workbook;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we want to parse it as multiple sheets
|
||||
* @return boolean
|
||||
*/
|
||||
protected function parseAsMultiple()
|
||||
{
|
||||
return ($this->excel->getSheetCount() > 1 && count($this->reader->getSelectedSheetIndices()) !== 1)
|
||||
|| Config::get('excel.import.force_sheets_collection', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the worksheet
|
||||
* @return RowCollection
|
||||
*/
|
||||
protected function parseWorksheet()
|
||||
{
|
||||
// Set the active worksheet
|
||||
$this->excel->setActiveSheetIndex($this->w);
|
||||
|
||||
// Fetch the labels
|
||||
$this->indices = $this->reader->hasHeading() ? $this->getIndices() : array();
|
||||
|
||||
// Parse the rows
|
||||
return $this->parseRows();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the indices
|
||||
* @return array
|
||||
*/
|
||||
protected function getIndices()
|
||||
{
|
||||
// Fetch the first row
|
||||
$this->row = $this->worksheet->getRowIterator($this->defaultStartRow)->current();
|
||||
|
||||
// Set empty labels array
|
||||
$this->indices = array();
|
||||
|
||||
// Loop through the cells
|
||||
foreach ($this->row->getCellIterator() as $this->cell)
|
||||
{
|
||||
$this->indices[] = $this->getIndex($this->cell);
|
||||
}
|
||||
|
||||
// Return the labels
|
||||
return $this->indices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index
|
||||
* @param $cell
|
||||
* @return string
|
||||
*/
|
||||
protected function getIndex($cell)
|
||||
{
|
||||
// Get heading type
|
||||
$config = Config::get('excel.import.heading', true);
|
||||
$config = $config === true ? 'slugged' : $config;
|
||||
|
||||
// Get value
|
||||
$value = $this->getOriginalIndex($cell);
|
||||
|
||||
switch ($config)
|
||||
{
|
||||
case 'slugged':
|
||||
return $this->getSluggedIndex($value, Config::get('excel.import.to_ascii', true));
|
||||
break;
|
||||
case 'slugged_with_count':
|
||||
$index = $this->getSluggedIndex($value, Config::get('excel.import.to_ascii', true));
|
||||
if(in_array($index,$this->indices)){
|
||||
$index = $this->appendOrIncreaseStringCount($index);
|
||||
}
|
||||
return $index;
|
||||
break;
|
||||
|
||||
case 'ascii':
|
||||
return $this->getAsciiIndex($value);
|
||||
break;
|
||||
|
||||
case 'hashed':
|
||||
return $this->getHashedIndex($value);
|
||||
break;
|
||||
|
||||
case 'trans':
|
||||
return $this->getTranslatedIndex($value);
|
||||
break;
|
||||
|
||||
case 'original':
|
||||
return $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Append or increase the count at the String like: test to test_1
|
||||
* @param string $index
|
||||
* @return string
|
||||
*/
|
||||
protected function appendOrIncreaseStringCount($index)
|
||||
{
|
||||
do {
|
||||
if (preg_match("/(\d+)$/",$index,$matches) === 1)
|
||||
{
|
||||
// increase +1
|
||||
$index = preg_replace_callback( "/(\d+)$/",
|
||||
function ($matches) {
|
||||
return ++$matches[1];
|
||||
}, $index);
|
||||
}
|
||||
else
|
||||
{
|
||||
$index .= '_1';
|
||||
}
|
||||
|
||||
} while(in_array($index,$this->indices));
|
||||
|
||||
return $index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slugged index
|
||||
* @param string $value
|
||||
* @param bool $ascii
|
||||
* @return string
|
||||
*/
|
||||
protected function getSluggedIndex($value, $ascii = false)
|
||||
{
|
||||
// Get original
|
||||
$separator = $this->reader->getSeparator();
|
||||
|
||||
// Convert to ascii when needed
|
||||
if ( $ascii )
|
||||
$value = $this->getAsciiIndex($value);
|
||||
|
||||
// Convert all dashes/underscores into separator
|
||||
$flip = $separator == '-' ? '_' : '-';
|
||||
$value = preg_replace('![' . preg_quote($flip) . ']+!u', $separator, $value);
|
||||
|
||||
// Remove all characters that are not the separator, letters, numbers, or whitespace.
|
||||
$value = preg_replace('![^' . preg_quote($separator) . '\pL\pN\s]+!u', '', mb_strtolower($value));
|
||||
|
||||
// Replace all separator characters and whitespace by a single separator
|
||||
$value = preg_replace('![' . preg_quote($separator) . '\s]+!u', $separator, $value);
|
||||
|
||||
return trim($value, $separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ASCII index
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
protected function getAsciiIndex($value)
|
||||
{
|
||||
return Str::ascii($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hahsed index
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
protected function getHashedIndex($value)
|
||||
{
|
||||
return md5($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get translated index
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
protected function getTranslatedIndex($value)
|
||||
{
|
||||
return trans($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get orignal indice
|
||||
* @param $cell
|
||||
* @return string
|
||||
*/
|
||||
protected function getOriginalIndex($cell)
|
||||
{
|
||||
return $cell->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the rows
|
||||
* @return RowCollection
|
||||
*/
|
||||
protected function parseRows()
|
||||
{
|
||||
// Set empty parsedRow array
|
||||
$parsedRows = new RowCollection();
|
||||
|
||||
// set sheet title
|
||||
$parsedRows->setTitle($this->excel->getActiveSheet()->getTitle());
|
||||
|
||||
// Get the start row
|
||||
$startRow = $this->getStartRow();
|
||||
|
||||
try {
|
||||
$rows = $this->worksheet->getRowIterator($startRow);
|
||||
} catch(PHPExcel_Exception $e) {
|
||||
$rows = [];
|
||||
}
|
||||
|
||||
// Loop through the rows inside the worksheet
|
||||
foreach ($rows as $this->row)
|
||||
{
|
||||
// Limit the results when needed
|
||||
if ( $this->hasReachedLimit() )
|
||||
break;
|
||||
|
||||
// Push the parsed cells inside the parsed rows
|
||||
$parsedRows->push($this->parseCells());
|
||||
|
||||
// Count the rows
|
||||
$this->currentRow++;
|
||||
}
|
||||
|
||||
// Return the parsed array
|
||||
return $parsedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the startrow
|
||||
* @return integer
|
||||
*/
|
||||
protected function getStartRow()
|
||||
{
|
||||
// Set default start row
|
||||
$startRow = $this->defaultStartRow;
|
||||
|
||||
// If the reader has a heading, skip the first row
|
||||
if ( $this->reader->hasHeading() )
|
||||
$startRow++;
|
||||
|
||||
// Get the amount of rows to skip
|
||||
$skip = $this->reader->getSkip();
|
||||
|
||||
// If we want to skip rows, add the amount of rows
|
||||
if ( $skip > 0 )
|
||||
$startRow = $startRow + $skip;
|
||||
|
||||
// Return the startrow
|
||||
return $startRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for the limit
|
||||
* @return boolean
|
||||
*/
|
||||
protected function hasReachedLimit()
|
||||
{
|
||||
// Get skip
|
||||
$limit = $this->reader->getLimit();
|
||||
|
||||
// If we have a limit, check if we hit this limit
|
||||
return $limit && $this->currentRow > $limit ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the cells of the given row
|
||||
* @return CellCollection
|
||||
*/
|
||||
protected function parseCells()
|
||||
{
|
||||
$i = 0;
|
||||
$parsedCells = array();
|
||||
|
||||
try {
|
||||
// Set the cell iterator
|
||||
$cellIterator = $this->row->getCellIterator();
|
||||
|
||||
// Ignore empty cells if needed
|
||||
$cellIterator->setIterateOnlyExistingCells($this->reader->needsIgnoreEmpty());
|
||||
|
||||
// Foreach cells
|
||||
foreach ($cellIterator as $this->cell)
|
||||
{
|
||||
// Check how we need to save the parsed array
|
||||
$index = ($this->reader->hasHeading() && isset($this->indices[$i])) ? $this->indices[$i] : $this->getIndexFromColumn();
|
||||
|
||||
// Check if we want to select this column
|
||||
if ( $this->cellNeedsParsing($index) )
|
||||
{
|
||||
// Set the value
|
||||
$parsedCells[(string) $index] = $this->parseCell($index);
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
} catch (PHPExcel_Exception $e) {
|
||||
// silently ignore the 'No cells exist within the specified range' error, but rethrow any others
|
||||
if ($e->getMessage() != 'No cells exist within the specified range') {
|
||||
throw $e;
|
||||
}
|
||||
// make sure that we return an empty CellCollection
|
||||
$parsedCells = array();
|
||||
}
|
||||
|
||||
// Return array with parsed cells
|
||||
return new CellCollection($parsedCells);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a single cell
|
||||
* @param integer $index
|
||||
* @return string
|
||||
*/
|
||||
protected function parseCell($index)
|
||||
{
|
||||
// If the cell is a date time
|
||||
if ( $this->cellIsDate($index) )
|
||||
{
|
||||
// Parse the date
|
||||
return $this->parseDate();
|
||||
}
|
||||
|
||||
// Check if we want calculated values or not
|
||||
elseif ( $this->reader->needsCalculation() )
|
||||
{
|
||||
// Get calculated value
|
||||
return $this->getCalculatedValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get real value
|
||||
return $this->getCellValue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cell value
|
||||
* @return string
|
||||
*/
|
||||
protected function getCellValue()
|
||||
{
|
||||
$value = $this->cell->getValue();
|
||||
|
||||
return $this->encode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the calculated value
|
||||
* @return string
|
||||
*/
|
||||
protected function getCalculatedValue()
|
||||
{
|
||||
$value = $this->cell->getCalculatedValue();
|
||||
|
||||
return $this->encode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode with iconv
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
protected function encode($value)
|
||||
{
|
||||
// Get input and output encoding
|
||||
list($input, $output) = array_values(Config::get('excel.import.encoding', array('UTF-8', 'UTF-8')));
|
||||
|
||||
// If they are the same, return the value
|
||||
if ( $input == $output )
|
||||
return $value;
|
||||
|
||||
// Encode
|
||||
return iconv($input, $output, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the date
|
||||
* @return Carbon\Carbon|string
|
||||
*/
|
||||
protected function parseDate()
|
||||
{
|
||||
// If the date needs formatting
|
||||
if ( $this->reader->needsDateFormatting() )
|
||||
{
|
||||
// Parse the date with carbon
|
||||
return $this->parseDateAsCarbon();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parse the date as a normal string
|
||||
return $this->parseDateAsString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse and return carbon object or formatted time string
|
||||
* @return Carbon\Carbon
|
||||
*/
|
||||
protected function parseDateAsCarbon()
|
||||
{
|
||||
// If has a date
|
||||
if ( $cellContent = $this->cell->getCalculatedValue() )
|
||||
{
|
||||
// Convert excel time to php date object
|
||||
$date = PHPExcel_Shared_Date::ExcelToPHPObject($this->cell->getCalculatedValue())->format('Y-m-d H:i:s');
|
||||
|
||||
// Parse with carbon
|
||||
$date = Carbon::parse($date);
|
||||
|
||||
// Format the date if wanted
|
||||
return $this->reader->getDateFormat() ? $date->format($this->reader->getDateFormat()) : $date;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return date string
|
||||
* @return string
|
||||
*/
|
||||
protected function parseDateAsString()
|
||||
{
|
||||
//Format the date to a formatted string
|
||||
return (string) PHPExcel_Style_NumberFormat::toFormattedString(
|
||||
$this->cell->getCalculatedValue(),
|
||||
$this->cell->getWorksheet()->getParent()
|
||||
->getCellXfByIndex($this->cell->getXfIndex())
|
||||
->getNumberFormat()
|
||||
->getFormatCode()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if cell is a date
|
||||
* @param integer $index
|
||||
* @return boolean
|
||||
*/
|
||||
protected function cellIsDate($index)
|
||||
{
|
||||
// if is a date or if is a date column
|
||||
if ( $this->reader->getDateColumns() )
|
||||
{
|
||||
return in_array($index, $this->reader->getDateColumns());
|
||||
}
|
||||
else
|
||||
{
|
||||
return PHPExcel_Shared_Date::isDateTime($this->cell);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if cells needs parsing
|
||||
* @return array
|
||||
*/
|
||||
protected function cellNeedsParsing($index)
|
||||
{
|
||||
// if no columns are selected or if the column is selected
|
||||
return !$this->hasSelectedColumns() || ($this->hasSelectedColumns() && in_array($index, $this->getSelectedColumns()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cell index from column
|
||||
* @return integer
|
||||
*/
|
||||
protected function getIndexFromColumn()
|
||||
{
|
||||
return PHPExcel_Cell::columnIndexFromString($this->cell->getColumn());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set selected columns
|
||||
* @param array $columns
|
||||
*/
|
||||
protected function setSelectedColumns($columns = array())
|
||||
{
|
||||
// Set the columns
|
||||
$this->columns = $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we have selected columns
|
||||
* @return boolean
|
||||
*/
|
||||
protected function hasSelectedColumns()
|
||||
{
|
||||
return !empty($this->columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set selected columns
|
||||
* @return array
|
||||
*/
|
||||
protected function getSelectedColumns()
|
||||
{
|
||||
// Set the columns
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset
|
||||
* @return void
|
||||
*/
|
||||
protected function reset()
|
||||
{
|
||||
$this->indices = array();
|
||||
$this->isParsed = false;
|
||||
}
|
||||
}
|
126
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/ViewParser.php
vendored
Normal file
126
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/ViewParser.php
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php namespace Maatwebsite\Excel\Parsers;
|
||||
|
||||
use Maatwebsite\Excel\Readers\Html;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel ViewParser
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class ViewParser {
|
||||
|
||||
/**
|
||||
* View file
|
||||
* @var string
|
||||
*/
|
||||
public $view;
|
||||
|
||||
/**
|
||||
* Data array
|
||||
* @var array
|
||||
*/
|
||||
public $data = array();
|
||||
|
||||
/**
|
||||
* View merge data
|
||||
* @var array
|
||||
*/
|
||||
public $mergeData = array();
|
||||
|
||||
/**
|
||||
* Construct the view parser
|
||||
* @param Html $reader
|
||||
* @return \Maatwebsite\Excel\Parsers\ViewParser
|
||||
*/
|
||||
public function __construct(Html $reader)
|
||||
{
|
||||
$this->reader = $reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the view
|
||||
* @param \Maatwebsite\Excel\Classes\LaravelExcelWorksheet $sheet
|
||||
* @return \Maatwebsite\Excel\Classes\LaravelExcelWorksheet
|
||||
*/
|
||||
public function parse($sheet)
|
||||
{
|
||||
$html = View::make($this->getView(), $this->getData(), $this->getMergeData())->render();
|
||||
|
||||
return $this->_loadHTML($sheet, $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the HTML
|
||||
* @param \Maatwebsite\Excel\Classes\LaravelExcelWorksheet $sheet
|
||||
* @param string $html
|
||||
* @return \Maatwebsite\Excel\Classes\LaravelExcelWorksheet
|
||||
*/
|
||||
protected function _loadHTML($sheet, $html)
|
||||
{
|
||||
return $this->reader->load($html, true, $sheet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view
|
||||
* @return string
|
||||
*/
|
||||
public function getView()
|
||||
{
|
||||
return $this->view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get merge data
|
||||
* @return array
|
||||
*/
|
||||
public function getMergeData()
|
||||
{
|
||||
return $this->mergeData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the view
|
||||
* @param bool|string $view
|
||||
*/
|
||||
public function setView($view = false)
|
||||
{
|
||||
if ($view)
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the data
|
||||
* @param array $data
|
||||
*/
|
||||
public function setData($data = array())
|
||||
{
|
||||
if (!empty($data))
|
||||
$this->data = array_merge($this->data, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the merge data
|
||||
* @param array $mergeData
|
||||
*/
|
||||
public function setMergeData($mergeData = array())
|
||||
{
|
||||
if (!empty($mergeData))
|
||||
$this->mergeData = array_merge($this->mergeData, $mergeData);
|
||||
}
|
||||
}
|
148
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/Batch.php
vendored
Normal file
148
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/Batch.php
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php namespace Maatwebsite\Excel\Readers;
|
||||
|
||||
use Closure;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Batch Importer
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class Batch {
|
||||
|
||||
/**
|
||||
* Excel object
|
||||
* @var Excel
|
||||
*/
|
||||
protected $excel;
|
||||
|
||||
/**
|
||||
* Batch files
|
||||
* @var array
|
||||
*/
|
||||
public $files = array();
|
||||
|
||||
/**
|
||||
* Set allowed file extensions
|
||||
* @var array
|
||||
*/
|
||||
protected $allowedFileExtensions = array(
|
||||
'xls',
|
||||
'xlsx',
|
||||
'csv'
|
||||
);
|
||||
|
||||
/**
|
||||
* Start the Batach
|
||||
* @param Excel $excel
|
||||
* @param array $files
|
||||
* @param Closure $callback
|
||||
* @return Excel
|
||||
*/
|
||||
public function start(Excel $excel, $files, Closure $callback)
|
||||
{
|
||||
// Set excel object
|
||||
$this->excel = $excel;
|
||||
|
||||
// Set files
|
||||
$this->_setFiles($files);
|
||||
|
||||
// Do the callback
|
||||
if ($callback instanceof Closure)
|
||||
{
|
||||
foreach ($this->getFiles() as $file)
|
||||
{
|
||||
// Load the file
|
||||
$excel = $this->excel->load($file);
|
||||
|
||||
// Do a callback with the loaded file
|
||||
call_user_func($callback, $excel, $file);
|
||||
}
|
||||
}
|
||||
|
||||
// Return our excel object
|
||||
return $this->excel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the files
|
||||
* @return array
|
||||
*/
|
||||
public function getFiles()
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the batch files
|
||||
* @param array|string $files
|
||||
* @throws LaravelExcelException
|
||||
* @return void
|
||||
*/
|
||||
protected function _setFiles($files)
|
||||
{
|
||||
// If the param is an array, these will be the files for the batch import
|
||||
if (is_array($files))
|
||||
{
|
||||
$this->files = $this->_getFilesByArray($files);
|
||||
}
|
||||
|
||||
// Get all the files inside a folder
|
||||
elseif (is_string($files))
|
||||
{
|
||||
$this->files = $this->_getFilesByFolder($files);
|
||||
}
|
||||
|
||||
// Check if files were found
|
||||
if (empty($this->files))
|
||||
throw new LaravelExcelException('[ERROR]: No files were found. Batch terminated.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set files by array
|
||||
* @param array $array
|
||||
* @return array
|
||||
*/
|
||||
protected function _getFilesByArray($array)
|
||||
{
|
||||
$files = array();
|
||||
// Make sure we have real paths
|
||||
foreach ($array as $i => $file)
|
||||
{
|
||||
$files[$i] = realpath($file) ? $file : base_path($file);
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all files inside a folder
|
||||
* @param string $folder
|
||||
* @return array
|
||||
*/
|
||||
protected function _getFilesByFolder($folder)
|
||||
{
|
||||
// Check if it's a real path
|
||||
if (!realpath($folder))
|
||||
$folder = base_path($folder);
|
||||
|
||||
// Find path names matching our pattern of excel extensions
|
||||
$glob = glob($folder . '/*.{' . implode(',', $this->allowedFileExtensions) . '}', GLOB_BRACE);
|
||||
|
||||
// If no matches, return empty array
|
||||
if ($glob === false) return array();
|
||||
|
||||
// Return files
|
||||
return array_filter($glob, function ($file)
|
||||
{
|
||||
return filetype($file) == 'file';
|
||||
});
|
||||
}
|
||||
}
|
113
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/ChunkedReadJob.php
vendored
Normal file
113
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/ChunkedReadJob.php
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace Maatwebsite\Excel\Readers;
|
||||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Maatwebsite\Excel\Filters\ChunkReadFilter;
|
||||
use SuperClosure\Serializer;
|
||||
|
||||
class ChunkedReadJob implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $startRow;
|
||||
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
private $callback;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
private $chunkSize;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
private $startIndex;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
private $file;
|
||||
|
||||
/**
|
||||
* @var null
|
||||
*/
|
||||
private $sheets;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $shouldQueue;
|
||||
|
||||
/**
|
||||
* ChunkedReadJob constructor.
|
||||
*
|
||||
* @param $file
|
||||
* @param null $sheets
|
||||
* @param int $startRow
|
||||
* @param $startIndex
|
||||
* @param $chunkSize
|
||||
* @param callable $callback
|
||||
* @param bool $shouldQueue
|
||||
*/
|
||||
public function __construct(
|
||||
$file,
|
||||
$sheets = null,
|
||||
$startRow,
|
||||
$startIndex,
|
||||
$chunkSize,
|
||||
callable $callback,
|
||||
$shouldQueue = true
|
||||
) {
|
||||
$this->startRow = $startRow;
|
||||
$this->chunkSize = $chunkSize;
|
||||
$this->startIndex = $startIndex;
|
||||
$this->file = $file;
|
||||
|
||||
$this->callback = $shouldQueue ? (new Serializer)->serialize($callback) : $callback;
|
||||
$this->sheets = $sheets;
|
||||
$this->shouldQueue = $shouldQueue;
|
||||
}
|
||||
|
||||
/***
|
||||
* Handle the read job
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$reader = app('excel.reader');
|
||||
$reader->injectExcel(app('phpexcel'));
|
||||
$reader->_init($this->file);
|
||||
|
||||
$filter = new ChunkReadFilter();
|
||||
$reader->reader->setLoadSheetsOnly($this->sheets);
|
||||
$reader->reader->setReadFilter($filter);
|
||||
$reader->reader->setReadDataOnly(true);
|
||||
|
||||
// Set the rows for the chunking
|
||||
$filter->setRows($this->startRow, $this->chunkSize);
|
||||
|
||||
// Load file with chunk filter enabled
|
||||
$reader->excel = $reader->reader->load($this->file);
|
||||
|
||||
// Slice the results
|
||||
$results = $reader->get()->slice($this->startIndex, $this->chunkSize);
|
||||
|
||||
$callback = $this->shouldQueue ? (new Serializer)->unserialize($this->callback) : $this->callback;
|
||||
|
||||
// Do a callback
|
||||
if (is_callable($callback)) {
|
||||
$break = call_user_func($callback, $results);
|
||||
}
|
||||
|
||||
$reader->_reset();
|
||||
unset($reader, $results);
|
||||
|
||||
if ($break) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
176
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/ConfigReader.php
vendored
Normal file
176
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/ConfigReader.php
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php namespace Maatwebsite\Excel\Readers;
|
||||
|
||||
use Closure;
|
||||
use PHPExcel;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Maatwebsite\Excel\Collections\SheetCollection;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel ConfigReader
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class ConfigReader {
|
||||
|
||||
/**
|
||||
* Excel object
|
||||
* @var PHPExcel
|
||||
*/
|
||||
public $excel;
|
||||
|
||||
/**
|
||||
* The sheet
|
||||
* @var LaravelExcelWorksheet
|
||||
*/
|
||||
public $sheet;
|
||||
|
||||
/**
|
||||
* The sheetname
|
||||
* @var string
|
||||
*/
|
||||
public $sheetName;
|
||||
|
||||
/**
|
||||
* Collection of sheets (through the config reader)
|
||||
* @var SheetCollection
|
||||
*/
|
||||
public $sheetCollection;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param PHPExcel $excel
|
||||
* @param string $config
|
||||
* @param callback $callback
|
||||
*/
|
||||
public function __construct(PHPExcel $excel, $config = 'excel.import', $callback = null)
|
||||
{
|
||||
// Set excel object
|
||||
$this->excel = $excel;
|
||||
|
||||
// config name
|
||||
$this->configName = $config;
|
||||
|
||||
// start
|
||||
$this->start($callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the import
|
||||
* @param bool|callable $callback $callback
|
||||
* @throws \PHPExcel_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function start($callback = false)
|
||||
{
|
||||
// Init a new sheet collection
|
||||
$this->sheetCollection = new SheetCollection();
|
||||
|
||||
// Get the sheet names
|
||||
if ($sheets = $this->excel->getSheetNames())
|
||||
{
|
||||
// Loop through the sheets
|
||||
foreach ($sheets as $index => $name)
|
||||
{
|
||||
// Set sheet name
|
||||
$this->sheetName = $name;
|
||||
|
||||
// Set sheet
|
||||
$this->sheet = $this->excel->setActiveSheetIndex($index);
|
||||
|
||||
// Do the callback
|
||||
if ($callback instanceof Closure)
|
||||
{
|
||||
call_user_func($callback, $this);
|
||||
}
|
||||
// If no callback, put it inside the sheet collection
|
||||
else
|
||||
{
|
||||
$this->sheetCollection->push(clone $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sheet collection
|
||||
* @return SheetCollection
|
||||
*/
|
||||
public function getSheetCollection()
|
||||
{
|
||||
return $this->sheetCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value by index
|
||||
* @param string $field
|
||||
* @return string|null
|
||||
*/
|
||||
protected function valueByIndex($field)
|
||||
{
|
||||
// Convert field name
|
||||
$field = snake_case($field);
|
||||
|
||||
// Get coordinate
|
||||
if ($coordinate = $this->getCoordinateByKey($field))
|
||||
{
|
||||
// return cell value by coordinate
|
||||
return $this->getCellValueByCoordinate($coordinate);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return cell value
|
||||
* @param string $coordinate
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getCellValueByCoordinate($coordinate)
|
||||
{
|
||||
if ($this->sheet)
|
||||
{
|
||||
if (str_contains($coordinate, ':'))
|
||||
{
|
||||
// We want to get a range of cells
|
||||
$values = $this->sheet->rangeToArray($coordinate);
|
||||
|
||||
return $values;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We want 1 specific cell
|
||||
return $this->sheet->getCell($coordinate)->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the coordinates from the config file
|
||||
* @param string $field
|
||||
* @return string|boolean
|
||||
*/
|
||||
protected function getCoordinateByKey($field)
|
||||
{
|
||||
return Config::get($this->configName . '.' . $this->sheetName . '.' . $field, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically get a value by config
|
||||
* @param string $field
|
||||
* @return string
|
||||
*/
|
||||
public function __get($field)
|
||||
{
|
||||
return $this->valueByIndex($field);
|
||||
}
|
||||
}
|
1367
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/HtmlReader.php
vendored
Normal file
1367
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/HtmlReader.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1275
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/LaravelExcelReader.php
vendored
Normal file
1275
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Readers/LaravelExcelReader.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
247
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Writers/CellWriter.php
vendored
Normal file
247
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Writers/CellWriter.php
vendored
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php namespace Maatwebsite\Excel\Writers;
|
||||
|
||||
use Maatwebsite\Excel\Classes\LaravelExcelWorksheet;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Excel writer
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class CellWriter {
|
||||
|
||||
/**
|
||||
* Current $sheet
|
||||
* @var LaravelExcelWorksheet
|
||||
*/
|
||||
public $sheet;
|
||||
|
||||
/**
|
||||
* Selected cells
|
||||
* @var array
|
||||
*/
|
||||
public $cells;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param array $cells
|
||||
* @param LaravelExcelWorksheet $sheet
|
||||
*/
|
||||
public function __construct($cells, LaravelExcelWorksheet $sheet)
|
||||
{
|
||||
$this->cells = $cells;
|
||||
$this->sheet = $sheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cell value
|
||||
* @param [type] $value
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
// Only set cell value for single cells
|
||||
if (!str_contains($this->cells, ':'))
|
||||
{
|
||||
$this->sheet->setCellValue($this->cells, $value);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the background
|
||||
* @param string $color
|
||||
* @param string $type
|
||||
* @param string $colorType
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setBackground($color, $type = 'solid', $colorType = 'rgb')
|
||||
{
|
||||
return $this->setColorStyle('fill', $color, $type, $colorType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the font color
|
||||
* @param string $color
|
||||
* @param string $colorType
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setFontColor($color, $colorType = 'rgb')
|
||||
{
|
||||
return $this->setColorStyle('font', $color, false, $colorType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the font
|
||||
* @param $styles
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setFont($styles)
|
||||
{
|
||||
return $this->setStyle('font', $styles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font family
|
||||
* @param string $family
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setFontFamily($family)
|
||||
{
|
||||
return $this->setStyle('font', array(
|
||||
'name' => $family
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font size
|
||||
* @param string $size
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setFontSize($size)
|
||||
{
|
||||
return $this->setStyle('font', array(
|
||||
'size' => $size
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font weight
|
||||
* @param boolean|string $bold
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setFontWeight($bold = true)
|
||||
{
|
||||
return $this->setStyle('font', array(
|
||||
'bold' => ($bold == 'bold' || $bold) ? true : false
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border
|
||||
* @param string $top
|
||||
* @param bool|string $right
|
||||
* @param bool|string $bottom
|
||||
* @param bool|string $left
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setBorder($top = 'none', $right = 'none', $bottom = 'none', $left = 'none')
|
||||
{
|
||||
// Set the border styles
|
||||
$styles = is_array($top) ? $top : array(
|
||||
'top' => array(
|
||||
'style' => $top
|
||||
),
|
||||
'left' => array(
|
||||
'style' => $left,
|
||||
),
|
||||
'right' => array(
|
||||
'style' => $right,
|
||||
),
|
||||
'bottom' => array(
|
||||
'style' => $bottom,
|
||||
)
|
||||
);
|
||||
|
||||
return $this->setStyle('borders', $styles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text rotation
|
||||
* @param integer $alignment
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setTextRotation($degrees)
|
||||
{
|
||||
$style = $this->getCellStyle()->getAlignment()->setTextRotation($degrees);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the alignment
|
||||
* @param string $alignment
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setAlignment($alignment)
|
||||
{
|
||||
return $this->setStyle('alignment', array(
|
||||
'horizontal' => $alignment
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set vertical alignment
|
||||
* @param string $alignment
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setValignment($alignment)
|
||||
{
|
||||
return $this->setStyle('alignment', array(
|
||||
'vertical' => $alignment
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text indent
|
||||
* @param integer $indent
|
||||
* @return CellWriter
|
||||
*/
|
||||
public function setTextIndent($indent)
|
||||
{
|
||||
$style = $this->getCellStyle()->getAlignment()->setIndent((int)$indent);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color style
|
||||
* @param $styleType
|
||||
* @param string $color
|
||||
* @param boolean $type
|
||||
* @param string $colorType
|
||||
* @return CellWriter
|
||||
*/
|
||||
protected function setColorStyle($styleType, $color, $type = false, $colorType = 'rgb')
|
||||
{
|
||||
// Set the styles
|
||||
$styles = is_array($color) ? $color : array(
|
||||
'type' => $type,
|
||||
'color' => array($colorType => str_replace('#', '', $color))
|
||||
);
|
||||
|
||||
return $this->setStyle($styleType, $styles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set style
|
||||
* @param $styleType
|
||||
* @param string $styles
|
||||
* @return CellWriter
|
||||
*/
|
||||
protected function setStyle($styleType, $styles)
|
||||
{
|
||||
// Get the cell style
|
||||
$style = $this->getCellStyle();
|
||||
|
||||
// Apply style from array
|
||||
$style->applyFromArray(array(
|
||||
$styleType => $styles
|
||||
));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cell style
|
||||
* @return \PHPExcel_Style
|
||||
*/
|
||||
protected function getCellStyle()
|
||||
{
|
||||
return $this->sheet->getStyle($this->cells);
|
||||
}
|
||||
}
|
642
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Writers/LaravelExcelWriter.php
vendored
Normal file
642
vendor/maatwebsite/excel/src/Maatwebsite/Excel/Writers/LaravelExcelWriter.php
vendored
Normal file
@@ -0,0 +1,642 @@
|
||||
<?php namespace Maatwebsite\Excel\Writers;
|
||||
|
||||
use Closure;
|
||||
use Carbon\Carbon;
|
||||
use PHPExcel_IOFactory;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Maatwebsite\Excel\Classes\FormatIdentifier;
|
||||
use Maatwebsite\Excel\Classes\LaravelExcelWorksheet;
|
||||
use Maatwebsite\Excel\Exceptions\LaravelExcelException;
|
||||
use Symfony\Component\Finder\Exception\AccessDeniedException;
|
||||
|
||||
/**
|
||||
*
|
||||
* LaravelExcel Excel writer
|
||||
*
|
||||
* @category Laravel Excel
|
||||
* @version 1.0.0
|
||||
* @package maatwebsite/excel
|
||||
* @copyright Copyright (c) 2013 - 2014 Maatwebsite (http://www.maatwebsite.nl)
|
||||
* @author Maatwebsite <info@maatwebsite.nl>
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
class LaravelExcelWriter {
|
||||
|
||||
/**
|
||||
* Spreadsheet filename
|
||||
* @var string
|
||||
*/
|
||||
public $filename;
|
||||
|
||||
/**
|
||||
* Spreadsheet title
|
||||
* @var string
|
||||
*/
|
||||
public $title;
|
||||
|
||||
/**
|
||||
* Excel object
|
||||
* @var \PHPExcel
|
||||
*/
|
||||
public $excel;
|
||||
|
||||
/**
|
||||
* Laravel response
|
||||
* @var Response
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* Spreadsheet writer
|
||||
* @var object
|
||||
*/
|
||||
public $writer;
|
||||
|
||||
/**
|
||||
* Excel sheet
|
||||
* @var LaravelExcelWorksheet
|
||||
*/
|
||||
protected $sheet;
|
||||
|
||||
/**
|
||||
* Parser
|
||||
* @var ViewParser
|
||||
*/
|
||||
public $parser;
|
||||
|
||||
/**
|
||||
* Default extension
|
||||
* @var string
|
||||
*/
|
||||
public $ext = 'xls';
|
||||
|
||||
/**
|
||||
* Path the file will be stored to
|
||||
* @var string
|
||||
*/
|
||||
public $storagePath = 'exports';
|
||||
|
||||
/**
|
||||
* Header Content-type
|
||||
* @var string
|
||||
*/
|
||||
protected $contentType;
|
||||
|
||||
/**
|
||||
* Spreadsheet is rendered
|
||||
* @var boolean
|
||||
*/
|
||||
protected $rendered = false;
|
||||
|
||||
/**
|
||||
* Construct writer
|
||||
* @param Response $response
|
||||
* @param FileSystem $filesystem
|
||||
* @param FormatIdentifier $identifier
|
||||
*/
|
||||
public function __construct(Response $response, FileSystem $filesystem, FormatIdentifier $identifier)
|
||||
{
|
||||
$this->response = $response;
|
||||
$this->filesystem = $filesystem;
|
||||
$this->identifier = $identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject the excel object
|
||||
* @param PHPExcel $excel
|
||||
* @param bool $reset
|
||||
* @return void
|
||||
*/
|
||||
public function injectExcel($excel, $reset = true)
|
||||
{
|
||||
$this->excel = $excel;
|
||||
|
||||
if ($reset)
|
||||
$this->_reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the spreadsheet title
|
||||
* @param string $title
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->getProperties()->setTitle($title);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the filename
|
||||
* @param $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setFileName($name)
|
||||
{
|
||||
$this->filename = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title
|
||||
* @return string
|
||||
*/
|
||||
public function getFileName()
|
||||
{
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Share view with all sheets
|
||||
* @param string $view
|
||||
* @param array $data
|
||||
* @param array $mergeData
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function shareView($view, $data = array(), $mergeData = array())
|
||||
{
|
||||
// Get the parser
|
||||
$this->getParser();
|
||||
|
||||
// Set the view inside the parser
|
||||
$this->parser->setView($view);
|
||||
$this->parser->setData($data);
|
||||
$this->parser->setMergeData($mergeData);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the view
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function setView()
|
||||
{
|
||||
return call_user_func_array(array($this, 'shareView'), func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the view
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function loadView()
|
||||
{
|
||||
return call_user_func_array(array($this, 'shareView'), func_get_args());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new sheet
|
||||
* @param string $title
|
||||
* @param callback|null $callback
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function sheet($title, $callback = null)
|
||||
{
|
||||
// Clone the active sheet
|
||||
$this->sheet = $this->excel->createSheet(null, $title);
|
||||
|
||||
// If a parser was set, inject it
|
||||
if ($this->parser)
|
||||
$this->sheet->setParser($this->parser);
|
||||
|
||||
// Set the sheet title
|
||||
$this->sheet->setTitle($title);
|
||||
|
||||
// Set the default page setup
|
||||
$this->sheet->setDefaultPageSetup();
|
||||
|
||||
// Do the callback
|
||||
if ($callback instanceof Closure)
|
||||
call_user_func($callback, $this->sheet);
|
||||
|
||||
// Autosize columns when no user didn't change anything about column sizing
|
||||
if (!$this->sheet->hasFixedSizeColumns())
|
||||
$this->sheet->setAutosize(Config::get('excel.export.autosize', false));
|
||||
|
||||
// Parse the sheet
|
||||
$this->sheet->parsed();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set data for the current sheet
|
||||
* @param array $array
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function with(Array $array)
|
||||
{
|
||||
// Add the vars
|
||||
$this->fromArray($array);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the spreadsheet
|
||||
* @param string $ext
|
||||
* @param array $headers
|
||||
* @throws LaravelExcelException
|
||||
*/
|
||||
public function export($ext = 'xls', Array $headers = array())
|
||||
{
|
||||
// Set the extension
|
||||
$this->ext = $ext;
|
||||
|
||||
//Fix borders for merged cells
|
||||
foreach($this->getAllSheets() as $sheet){
|
||||
|
||||
foreach($sheet->getMergeCells() as $cells){
|
||||
|
||||
$style = $sheet->getStyle(explode(':', $cells)[0]);
|
||||
|
||||
$sheet->duplicateStyle($style, $cells);
|
||||
}
|
||||
}
|
||||
|
||||
// Render the file
|
||||
$this->_render();
|
||||
|
||||
// Download the file
|
||||
$this->_download($headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert and existing file to newly requested extension
|
||||
* @param $ext
|
||||
* @param array $headers
|
||||
*/
|
||||
public function convert($ext, Array $headers = array())
|
||||
{
|
||||
$this->export($ext, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export and download the spreadsheet
|
||||
* @param string $ext
|
||||
* @param array $headers
|
||||
*/
|
||||
public function download($ext = 'xls', Array $headers = array())
|
||||
{
|
||||
$this->export($ext, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the spreadsheet file as a string
|
||||
* @param string $ext
|
||||
* @return string
|
||||
* @throws LaravelExcelException
|
||||
*/
|
||||
public function string($ext = 'xls')
|
||||
{
|
||||
// Set the extension
|
||||
$this->ext = $ext;
|
||||
|
||||
// Render the file
|
||||
$this->_render();
|
||||
|
||||
// Check if writer isset
|
||||
if (!$this->writer)
|
||||
throw new LaravelExcelException('[ERROR] No writer was set.');
|
||||
|
||||
//Capture the content as a string and return it
|
||||
ob_start();
|
||||
|
||||
$this->writer->save('php://output');
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Download a file
|
||||
* @param array $headers
|
||||
* @throws LaravelExcelException
|
||||
*/
|
||||
protected function _download(Array $headers = array())
|
||||
{
|
||||
// Set the headers
|
||||
$this->_setHeaders(
|
||||
$headers,
|
||||
array(
|
||||
'Content-Type' => $this->contentType,
|
||||
'Content-Disposition' => 'attachment; filename="' . $this->filename . '.' . $this->ext . '"',
|
||||
'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', // Date in the past
|
||||
'Last-Modified' => Carbon::now()->format('D, d M Y H:i:s'),
|
||||
'Cache-Control' => 'cache, must-revalidate',
|
||||
'Pragma' => 'public'
|
||||
)
|
||||
);
|
||||
|
||||
// Check if writer isset
|
||||
if (!$this->writer)
|
||||
throw new LaravelExcelException('[ERROR] No writer was set.');
|
||||
|
||||
|
||||
// Download
|
||||
$this->writer->save('php://output');
|
||||
|
||||
// End the script to prevent corrupted xlsx files
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the excel file to the server
|
||||
* @param string $ext
|
||||
* @param boolean $path
|
||||
* @param boolean $returnInfo
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function store($ext = 'xls', $path = false, $returnInfo = false)
|
||||
{
|
||||
// Set the storage path
|
||||
$this->_setStoragePath($path);
|
||||
|
||||
// Set the extension
|
||||
$this->ext = $ext;
|
||||
|
||||
// Render the XLS
|
||||
$this->_render();
|
||||
|
||||
// Set the storage path and file
|
||||
$toStore = $this->storagePath . '/' . $this->filename . '.' . $this->ext;
|
||||
|
||||
// Save the file to specified location
|
||||
$this->writer->save($toStore);
|
||||
|
||||
// Return file info
|
||||
if ($this->returnInfo($returnInfo))
|
||||
{
|
||||
// Send back information about the stored file
|
||||
return array(
|
||||
'full' => $toStore,
|
||||
'path' => $this->storagePath,
|
||||
'file' => $this->filename . '.' . $this->ext,
|
||||
'title' => $this->filename,
|
||||
'ext' => $this->ext
|
||||
);
|
||||
}
|
||||
|
||||
// Return itself
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we want to return info or itself
|
||||
* @param boolean $returnInfo
|
||||
* @return boolean
|
||||
*/
|
||||
public function returnInfo($returnInfo = false)
|
||||
{
|
||||
return $returnInfo ? $returnInfo : Config::get('excel.export.store.returnInfo', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the excel file to the server
|
||||
* @param str|string $ext The file extension
|
||||
* @param bool|str $path The save path
|
||||
* @param bool $returnInfo
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function save($ext = 'xls', $path = false, $returnInfo = false)
|
||||
{
|
||||
return $this->store($ext, $path, $returnInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start render of a new spreadsheet
|
||||
* @throws LaravelExcelException
|
||||
* @return void
|
||||
*/
|
||||
protected function _render()
|
||||
{
|
||||
// There should be enough sheets to continue rendering
|
||||
if ($this->excel->getSheetCount() < 0)
|
||||
throw new LaravelExcelException('[ERROR] Aborting spreadsheet render: no sheets were created.');
|
||||
|
||||
// Set the format
|
||||
$this->_setFormat();
|
||||
|
||||
// Set the writer
|
||||
$this->_setWriter();
|
||||
|
||||
// File has been rendered
|
||||
$this->rendered = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view parser
|
||||
* @return PHPExcel
|
||||
*/
|
||||
public function getExcel()
|
||||
{
|
||||
return $this->excel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view parser
|
||||
* @return ViewParser
|
||||
*/
|
||||
public function getParser()
|
||||
{
|
||||
// Init the parser
|
||||
if (!$this->parser)
|
||||
$this->parser = app('excel.parsers.view');
|
||||
|
||||
return $this->parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sheet
|
||||
* @return LaravelExcelWorksheet
|
||||
*/
|
||||
public function getSheet()
|
||||
{
|
||||
return $this->sheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set attributes
|
||||
* @param string $setter
|
||||
* @param array $params
|
||||
*/
|
||||
protected function _setAttribute($setter, $params)
|
||||
{
|
||||
// Get the key
|
||||
$key = lcfirst(str_replace('set', '', $setter));
|
||||
|
||||
// If is an allowed property
|
||||
if ($this->excel->isChangeableProperty($setter))
|
||||
{
|
||||
// Set the properties
|
||||
call_user_func_array(array($this->excel->getProperties(), $setter), $params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the write format
|
||||
* @return void
|
||||
*/
|
||||
protected function _setFormat()
|
||||
{
|
||||
// Get extension
|
||||
$this->ext = strtolower($this->ext);
|
||||
|
||||
// get the file format
|
||||
$this->format = $this->identifier->getFormatByExtension($this->ext);
|
||||
|
||||
// Get content type
|
||||
$this->contentType = $this->identifier->getContentTypeByFormat($this->format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the writer
|
||||
* @return PHPExcel_***_Writer
|
||||
*/
|
||||
protected function _setWriter()
|
||||
{
|
||||
// Set pdf renderer
|
||||
if ($this->format == 'PDF')
|
||||
{
|
||||
$this->setPdfRenderer();
|
||||
}
|
||||
|
||||
// Create the writer
|
||||
$this->writer = PHPExcel_IOFactory::createWriter($this->excel, $this->format);
|
||||
|
||||
// Set CSV delimiter
|
||||
if ($this->format == 'CSV')
|
||||
{
|
||||
$this->writer->setDelimiter(Config::get('excel.csv.delimiter', ','));
|
||||
$this->writer->setEnclosure(Config::get('excel.csv.enclosure', '"'));
|
||||
$this->writer->setLineEnding(Config::get('excel::csv.line_ending', "\r\n"));
|
||||
$this->writer->setUseBOM(Config::get('excel.csv.use_bom', false));
|
||||
}
|
||||
|
||||
// Set CSV delimiter
|
||||
if ($this->format == 'PDF')
|
||||
{
|
||||
$this->writer->writeAllSheets();
|
||||
}
|
||||
|
||||
// Calculation settings
|
||||
$this->writer->setPreCalculateFormulas(Config::get('excel.export.calculate', false));
|
||||
|
||||
// Include Charts
|
||||
$this->writer->setIncludeCharts(Config::get('excel.export.includeCharts', false));
|
||||
|
||||
return $this->writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pdf renderer
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function setPdfRenderer()
|
||||
{
|
||||
// Get the driver name
|
||||
$driver = Config::get('excel.export.pdf.driver');
|
||||
$path = Config::get('excel.export.pdf.drivers.' . $driver . '.path');
|
||||
|
||||
// Disable autoloading for dompdf
|
||||
if(! defined("DOMPDF_ENABLE_AUTOLOAD")){
|
||||
define("DOMPDF_ENABLE_AUTOLOAD", false);
|
||||
}
|
||||
|
||||
// Set the pdf renderer
|
||||
if (!\PHPExcel_Settings::setPdfRenderer($driver, $path))
|
||||
throw new \Exception("{$driver} could not be found. Make sure you've included it in your composer.json");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the headers
|
||||
* @param $headers
|
||||
* @throws LaravelExcelException
|
||||
*/
|
||||
protected function _setHeaders(Array $headers = array(), Array $default)
|
||||
{
|
||||
if (headers_sent()) throw new LaravelExcelException('[ERROR]: Headers already sent');
|
||||
|
||||
// Merge the default headers with the overruled headers
|
||||
$headers = array_merge($default, $headers);
|
||||
|
||||
foreach ($headers as $header => $value)
|
||||
{
|
||||
header($header . ': ' . $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the storage path
|
||||
* @param bool $path
|
||||
* @return void
|
||||
*/
|
||||
protected function _setStoragePath($path = false)
|
||||
{
|
||||
// Get the default path
|
||||
$path = $path ? $path : Config::get('excel.export.store.path', storage_path($this->storagePath));
|
||||
|
||||
// Trim of slashes, to makes sure we won't add them double
|
||||
$this->storagePath = rtrim($path, '/');
|
||||
|
||||
// Make sure the storage path exists
|
||||
if (!$this->filesystem->exists($this->storagePath)) {
|
||||
$this->filesystem->makeDirectory($this->storagePath, 0777, true);
|
||||
}
|
||||
|
||||
if (!$this->filesystem->isWritable($this->storagePath)) {
|
||||
throw new LaravelExcelException("Permission denied to the storage path");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the writer
|
||||
* @return void
|
||||
*/
|
||||
protected function _reset()
|
||||
{
|
||||
$this->excel->disconnectWorksheets();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call methods
|
||||
* @param string $method
|
||||
* @param array $params
|
||||
* @throws LaravelExcelException
|
||||
* @return LaravelExcelWriter
|
||||
*/
|
||||
public function __call($method, $params)
|
||||
{
|
||||
// If the dynamic call starts with "set"
|
||||
if (starts_with($method, 'set') && $this->excel->isChangeableProperty($method))
|
||||
{
|
||||
$this->_setAttribute($method, $params);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// Call a php excel method
|
||||
elseif (method_exists($this->excel, $method))
|
||||
{
|
||||
// Call the method from the excel object with the given params
|
||||
$return = call_user_func_array(array($this->excel, $method), $params);
|
||||
|
||||
return $return ? $return : $this;
|
||||
}
|
||||
|
||||
throw new LaravelExcelException('[ERROR] Writer method [' . $method . '] does not exist.');
|
||||
}
|
||||
}
|
691
vendor/maatwebsite/excel/src/config/excel.php
vendored
Normal file
691
vendor/maatwebsite/excel/src/config/excel.php
vendored
Normal file
@@ -0,0 +1,691 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
|
||||
'cache' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable/Disable cell caching
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'enable' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Caching driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Set the caching driver
|
||||
|
|
||||
| Available methods:
|
||||
| memory|gzip|serialized|igbinary|discISAM|apc|memcache|temp|wincache|sqlite|sqlite3
|
||||
|
|
||||
*/
|
||||
'driver' => 'memory',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'settings' => array(
|
||||
|
||||
'memoryCacheSize' => '32MB',
|
||||
'cacheTime' => 600
|
||||
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Memcache settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'memcache' => array(
|
||||
|
||||
'host' => 'localhost',
|
||||
'port' => 11211,
|
||||
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache dir (for discISAM)
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'dir' => storage_path('cache')
|
||||
),
|
||||
|
||||
'properties' => array(
|
||||
'creator' => 'Maatwebsite',
|
||||
'lastModifiedBy' => 'Maatwebsite',
|
||||
'title' => 'Spreadsheet',
|
||||
'description' => 'Default spreadsheet export',
|
||||
'subject' => 'Spreadsheet export',
|
||||
'keywords' => 'maatwebsite, excel, export',
|
||||
'category' => 'Excel',
|
||||
'manager' => 'Maatwebsite',
|
||||
'company' => 'Maatwebsite',
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sheets settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'sheets' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default page setup
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'pageSetup' => array(
|
||||
'orientation' => 'portrait',
|
||||
'paperSize' => '9',
|
||||
'scale' => '100',
|
||||
'fitToPage' => false,
|
||||
'fitToHeight' => true,
|
||||
'fitToWidth' => true,
|
||||
'columnsToRepeatAtLeft' => array('', ''),
|
||||
'rowsToRepeatAtTop' => array(0, 0),
|
||||
'horizontalCentered' => false,
|
||||
'verticalCentered' => false,
|
||||
'printArea' => null,
|
||||
'firstPageNumber' => null,
|
||||
),
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Creator
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The default creator of a new Excel file
|
||||
|
|
||||
*/
|
||||
|
||||
'creator' => 'Maatwebsite',
|
||||
|
||||
'csv' => array(
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Delimiter
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The default delimiter which will be used to read out a CSV file
|
||||
|
|
||||
*/
|
||||
|
||||
'delimiter' => ',',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enclosure
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'enclosure' => '"',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Line endings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'line_ending' => "\r\n",
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| setUseBom
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'use_bom' => false
|
||||
),
|
||||
|
||||
'export' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autosize columns
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Disable/enable column autosize or set the autosizing for
|
||||
| an array of columns ( array('A', 'B') )
|
||||
|
|
||||
*/
|
||||
'autosize' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autosize method
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX
|
||||
| The default is based on an estimate, which does its calculation based
|
||||
| on the number of characters in the cell value (applying any calculation
|
||||
| and format mask, and allowing for wordwrap and rotation) and with an
|
||||
| "arbitrary" adjustment based on the font (Arial, Calibri or Verdana,
|
||||
| defaulting to Calibri if any other font is used) and a proportional
|
||||
| adjustment for the font size.
|
||||
|
|
||||
| --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT
|
||||
| The second method is more accurate, based on actual style formatting as
|
||||
| well (bold, italic, etc), and is calculated by generating a gd2 imagettf
|
||||
| bounding box and using its dimensions to determine the size; but this
|
||||
| method is significantly slower, and its accuracy is still dependent on
|
||||
| having the appropriate fonts installed.
|
||||
|
|
||||
*/
|
||||
'autosize-method' => PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Auto generate table heading
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If set to true, the array indices (or model attribute names)
|
||||
| will automatically be used as first row (table heading)
|
||||
|
|
||||
*/
|
||||
'generate_heading_by_indices' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Auto set alignment on merged cells
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'merged_cell_alignment' => 'left',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Pre-calculate formulas during export
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'calculate' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Include Charts during export
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'includeCharts' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default sheet settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'sheets' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default page margin
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| 1) When set to false, default margins will be used
|
||||
| 2) It's possible to enter a single margin which will
|
||||
| be used for all margins.
|
||||
| 3) Alternatively you can pass an array with 4 margins
|
||||
| Default order: array(top, right, bottom, left)
|
||||
|
|
||||
*/
|
||||
'page_margin' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Value in source array that stands for blank cell
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'nullValue' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Insert array starting from this cell address as the top left coordinate
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'startCell' => 'A1',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Apply strict comparison when testing for null values in the array
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'strictNullComparison' => false
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Store settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'store' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The path we want to save excel file to
|
||||
|
|
||||
*/
|
||||
'path' => storage_path('exports'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Return info
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Whether we want to return information about the stored file or not
|
||||
|
|
||||
*/
|
||||
'returnInfo' => false
|
||||
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PDF Settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'pdf' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PDF Drivers
|
||||
|--------------------------------------------------------------------------
|
||||
| Supported: DomPDF, tcPDF, mPDF
|
||||
*/
|
||||
'driver' => 'DomPDF',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PDF Driver settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'drivers' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DomPDF settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'DomPDF' => array(
|
||||
'path' => base_path('vendor/dompdf/dompdf/')
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| tcPDF settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'tcPDF' => array(
|
||||
'path' => base_path('vendor/tecnick.com/tcpdf/')
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| mPDF settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'mPDF' => array(
|
||||
'path' => base_path('vendor/mpdf/mpdf/')
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
'filters' => array(
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register read filters
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'registered' => array(
|
||||
'chunk' => 'Maatwebsite\Excel\Filters\ChunkReadFilter'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable certain filters for every file read
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'enabled' => array()
|
||||
),
|
||||
|
||||
'import' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Has heading
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The sheet has a heading (first) row which we can use as attribute names
|
||||
|
|
||||
| Options: true|false|slugged|slugged_with_count|ascii|numeric|hashed|trans|original
|
||||
|
|
||||
*/
|
||||
|
||||
'heading' => 'slugged',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| First Row with data or heading of data
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If the heading row is not the first row, or the data doesn't start
|
||||
| on the first row, here you can change the start row.
|
||||
|
|
||||
*/
|
||||
|
||||
'startRow' => 1,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cell name word separator
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The default separator which is used for the cell names
|
||||
| Note: only applies to 'heading' settings 'true' && 'slugged'
|
||||
|
|
||||
*/
|
||||
|
||||
'separator' => '_',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Include Charts during import
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'includeCharts' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sheet heading conversion
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Convert headings to ASCII
|
||||
| Note: only applies to 'heading' settings 'true' && 'slugged'
|
||||
|
|
||||
*/
|
||||
|
||||
'to_ascii' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Import encoding
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'encoding' => array(
|
||||
|
||||
'input' => 'UTF-8',
|
||||
'output' => 'UTF-8'
|
||||
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Calculate
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By default cells with formulas will be calculated.
|
||||
|
|
||||
*/
|
||||
|
||||
'calculate' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Ignore empty cells
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By default empty cells are not ignored
|
||||
|
|
||||
*/
|
||||
|
||||
'ignoreEmpty' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Force sheet collection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| For a sheet collection even when there is only 1 sheets.
|
||||
| When set to false and only 1 sheet found, the parsed file will return
|
||||
| a row collection instead of a sheet collection.
|
||||
| When set to true, it will return a sheet collection instead.
|
||||
|
|
||||
*/
|
||||
'force_sheets_collection' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Date format
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The format dates will be parsed to
|
||||
|
|
||||
*/
|
||||
|
||||
'dates' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable/disable date formatting
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'enabled' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default date format
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If set to false, a carbon object will return
|
||||
|
|
||||
*/
|
||||
'format' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Date columns
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'columns' => array()
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Import sheets by config
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'sheets' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Example sheet
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Example sheet "test" will grab the firstname at cell A2
|
||||
|
|
||||
*/
|
||||
|
||||
'test' => array(
|
||||
|
||||
'firstname' => 'A2'
|
||||
|
||||
)
|
||||
|
||||
)
|
||||
),
|
||||
|
||||
'views' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Styles
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The default styles which will be used when parsing a view
|
||||
|
|
||||
*/
|
||||
|
||||
'styles' => array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Table headings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'th' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 12,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Strong tags
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'strong' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 12,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bold tags
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'b' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 12,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Italic tags
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'i' => array(
|
||||
'font' => array(
|
||||
'italic' => true,
|
||||
'size' => 12,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Heading 1
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'h1' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 24,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Heading 2
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'h2' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 18,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Heading 2
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'h3' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 13.5,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Heading 4
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'h4' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 12,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Heading 5
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'h5' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 10,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Heading 6
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'h6' => array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
'size' => 7.5,
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Hyperlinks
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'a' => array(
|
||||
'font' => array(
|
||||
'underline' => true,
|
||||
'color' => array('argb' => 'FF0000FF'),
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Horizontal rules
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
'hr' => array(
|
||||
'borders' => array(
|
||||
'bottom' => array(
|
||||
'style' => 'thin',
|
||||
'color' => array('FF000000')
|
||||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
);
|
Reference in New Issue
Block a user