Skip to content

Commit

Permalink
Merge pull request thebuggenie#573 from milkyway-git/patch-1
Browse files Browse the repository at this point in the history
Replace deprecated phpexcel by phpspreadsheet
  • Loading branch information
zegenie authored Apr 4, 2021
2 parents b246178 + a460622 commit 99c1967
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"webit/eval-math" : "^1.0",
"mustangostang/spyc": "0.5.*",
"realityking/pchart": "dev-master",
"phpoffice/phpexcel": "~1.8",
"phpoffice/phpspreadsheet": "^1.17.0",
"kriswallsmith/assetic": "~1.2",
"lib-pcre" : ">=8.0",
"net/http" : "^1.1",
Expand Down
16 changes: 6 additions & 10 deletions core/modules/search/Components.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

use thebuggenie\core\framework,
thebuggenie\core\entities,
thebuggenie\core\entities\tables;
thebuggenie\core\entities\tables,
PhpOffice\PhpSpreadsheet\Spreadsheet;

class Components extends framework\ActionComponent
{
Expand Down Expand Up @@ -120,15 +121,10 @@ public function componentResults_normal_sheet()
{
$this->custom_columns = entities\CustomDatatype::getAll();
$this->cc = (isset($this->cc)) ? $this->cc : 0;
require realpath(THEBUGGENIE_VENDOR_PATH) . DS . 'phpoffice' . DS . 'phpexcel' . DS . 'Classes' . DS . 'PHPExcel.php';
$phpexcel = new \PHPExcel();
foreach ($phpexcel->getAllSheets() as $index => $sheet)
{
$phpexcel->removeSheetByIndex($index);
}

$this->phpexcel = $phpexcel;
$this->sheet = $phpexcel->createSheet();
require realpath(THEBUGGENIE_VENDOR_PATH) . DS . 'phpoffice' . DS . 'phpspreadsheet' . DS . 'src' . DS . 'PhpSpreadsheet' . DS . 'Spreadsheet.php';
$spreadsheet = new Spreadsheet();
$this->spreadsheet = $spreadsheet;
$this->sheet = $spreadsheet->getActiveSheet();
}

public function componentResults_todo()
Expand Down
4 changes: 2 additions & 2 deletions core/modules/search/templates/_results_normal_sheet.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@

switch ($format) {
case 'xlsx':
$objWriter = new \PHPExcel_Writer_Excel2007($phpexcel);
$objWriter = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="issues.xlsx"');
break;
case 'ods':
default:
$objWriter = new \PhpOffice\PhpSpreadsheet\Writer\Ods($spreadsheet);
header('Content-Type: application/vnd.oasis.opendocument.spreadsheet');
header('Content-Disposition: attachment;filename="issues.ods"');
$objWriter = new \PHPExcel_Writer_OpenDocument($phpexcel);
}

header('Cache-Control: max-age=0');
Expand Down

0 comments on commit 99c1967

Please sign in to comment.