Skip to content
Permalink
Browse files

升级 PHPExcel 到 PhpSpreadsheet

  • Loading branch information...
fengkaijia committed Jun 17, 2019
1 parent 780b65f commit 9d013f883006ad9f7e95387f4e0989f5c5ba8c2e
Showing with 13 additions and 13 deletions.
  1. +11 −11 application/controllers/Admin.php
  2. +1 −1 application/libraries/Excel.php
  3. +1 −1 composer.json
@@ -815,10 +815,10 @@ function export($action = 'guide')
//生成表头
foreach($columns as $column)
{
$this->excel->getActiveSheet()->setCellValueByColumnAndRow($column['order'], 1, $column['name']);
$this->excel->getActiveSheet()->getStyleByColumnAndRow($column['order'], 1)->getFont()->setBold(true);
$this->excel->getActiveSheet()->getStyleByColumnAndRow($column['order'], 1)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$this->excel->getActiveSheet()->getStyleByColumnAndRow($column['order'], 1)->getFill()->getStartColor()->setRGB('D3D3D3');
$this->excel->getActiveSheet()->setCellValueByColumnAndRow($column['order'] + 1, 1, $column['name']);
$this->excel->getActiveSheet()->getStyleByColumnAndRow($column['order'] + 1, 1)->getFont()->setBold(true);
$this->excel->getActiveSheet()->getStyleByColumnAndRow($column['order'] + 1, 1)->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID);
$this->excel->getActiveSheet()->getStyleByColumnAndRow($column['order'] + 1, 1)->getFill()->getStartColor()->setRGB('D3D3D3');
}
//写入数据
@@ -831,10 +831,10 @@ function export($action = 'guide')
if(isset($column['type']))
{
if($column['type'] == 'longtext')
$this->excel->getActiveSheet()->getCellByColumnAndRow($column['order'], $current_row)->setValueExplicit(isset($list_single[$column_id]) ? $list_single[$column_id] : NULL, PHPExcel_Cell_DataType::TYPE_STRING);
$this->excel->getActiveSheet()->getCellByColumnAndRow($column['order'] + 1, $current_row)->setValueExplicit(isset($list_single[$column_id]) ? $list_single[$column_id] : NULL, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
}
else
$this->excel->getActiveSheet()->setCellValueByColumnAndRow($column['order'], $current_row, isset($list_single[$column_id]) ? $list_single[$column_id] : NULL);
$this->excel->getActiveSheet()->setCellValueByColumnAndRow($column['order'] + 1, $current_row, isset($list_single[$column_id]) ? $list_single[$column_id] : NULL);
}
}
}
@@ -848,17 +848,17 @@ function export($action = 'guide')
switch($format)
{
case 'xls':
$io = 'Excel5';
$io = 'Xls';
break;
case 'xlsx':
$io = 'Excel2007';
$io = 'Xlsx';
break;
case 'pdf':
case 'html':
$io = 'HTML';
$io = 'Html';
break;
case 'csv':
$io = 'CSV';
$io = 'Csv';
break;
default:
$this->ui->alert('导出格式不支持。', 'warning', true);
@@ -881,7 +881,7 @@ function export($action = 'guide')
//生成内容
ob_start();
$writer = PHPExcel_IOFactory::createWriter($this->excel, $io);
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($this->excel, $io);
if(in_array($format, array('html', 'pdf')))
$writer->writeAllSheets();
@@ -11,7 +11,7 @@
* @package iPlacard
* @since 2.0
*/
class Excel extends \PHPExcel
class Excel extends \PhpOffice\PhpSpreadsheet\Spreadsheet
{
function __construct()
{
@@ -16,7 +16,7 @@
"imunc/iplacard-3rdparty": "2.4.*",
"codeigniter/framework": "3.1.*",
"codeigniter/translations": "3.1.*",
"phpoffice/phpexcel": "1.8.*"
"phpoffice/phpspreadsheet": "1.7.*"
},
"repositories": [
{

0 comments on commit 9d013f8

Please sign in to comment.
You can’t perform that action at this time.