| @@ -252,31 +252,26 @@ | ||
| 252 | 252 | * @param array $rows The array of data. |
| 253 | 253 | * @param string $filename The name of the file to use. |
| 254 | 254 | */ |
| 255 | 255 | private function _getExcel( $rows, $filename ) { |
| 256 | - // PHPExcel did not like sheet names longer than 31 characters and we will assume the same with PhpSpreadsheet | |
| 256 | + // PHPExcel does not like sheet names longer than 31 characters. | |
| 257 | 257 | $chart = substr( $filename, 0, 30 ); |
| 258 | 258 | $filename .= '.xlsx'; |
| 259 | 259 | |
| 260 | - $vendor_file = VISUALIZER_ABSPATH . '/vendor/autoload.php'; | |
| 261 | - if ( is_readable( $vendor_file ) ) { | |
| 262 | - include_once( $vendor_file ); | |
| 263 | - } | |
| 264 | - | |
| 265 | 260 | $xlsData = ''; |
| 266 | - if ( class_exists( 'PhpOffice\PhpSpreadsheet\Spreadsheet' ) ) { | |
| 267 | - $doc = new PhpOffice\PhpSpreadsheet\Spreadsheet(); | |
| 261 | + if ( class_exists( 'PHPExcel' ) ) { | |
| 262 | + $doc = new PHPExcel(); | |
| 268 | 263 | $doc->getActiveSheet()->fromArray( $rows, null, 'A1' ); |
| 269 | 264 | $doc->getActiveSheet()->setTitle( sanitize_title( $chart ) ); |
| 270 | 265 | $doc = apply_filters( 'visualizer_excel_doc', $doc ); |
| 271 | - $writer = PhpOffice\PhpSpreadsheet\IOFactory::createWriter( $doc, 'Xlsx' ); | |
| 266 | + $writer = PHPExcel_IOFactory::createWriter( $doc, 'Excel2007' ); | |
| 272 | 267 | ob_start(); |
| 273 | 268 | $writer->save( 'php://output' ); |
| 274 | 269 | $xlsData = ob_get_contents(); |
| 275 | 270 | ob_end_clean(); |
| 276 | 271 | } else { |
| 277 | - do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'Class PhpOffice\PhpSpreadsheet\Spreadsheet does not exist!', 'error', __FILE__, __LINE__ ); | |
| 278 | - error_log( 'Class PhpOffice\PhpSpreadsheet\Spreadsheet does not exist!' ); | |
| 272 | + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'Class PHPExcel does not exist!', 'error', __FILE__, __LINE__ ); | |
| 273 | + error_log( 'Class PHPExcel does not exist!' ); | |
| 279 | 274 | } |
| 280 | 275 | return array( |
| 281 | 276 | 'csv' => 'data:application/vnd.ms-excel;base64,' . base64_encode( $xlsData ), |
| 282 | 277 | 'name' => $filename, |