| @@ -248,27 +248,20 @@ | ||
| 248 | 248 | * @param array $rows The array of data. |
| 249 | 249 | * @param string $filename The name of the file to use. |
| 250 | 250 | */ |
| 251 | 251 | private function _getExcel( $rows, $filename ) { |
| 252 | - // PHPExcel does not like sheet names longer than 31 characters. | |
| 253 | - $chart = substr( $filename, 0, 30 ); | |
| 252 | + $chart = $filename; | |
| 254 | 253 | $filename .= '.xlsx'; |
| 255 | 254 | |
| 256 | - $xlsData = ''; | |
| 257 | - if ( class_exists( 'PHPExcel' ) ) { | |
| 258 | - $doc = new PHPExcel(); | |
| 259 | - $doc->getActiveSheet()->fromArray( $rows, null, 'A1' ); | |
| 260 | - $doc->getActiveSheet()->setTitle( $chart ); | |
| 261 | - $doc = apply_filters( 'visualizer_excel_doc', $doc ); | |
| 262 | - $writer = PHPExcel_IOFactory::createWriter( $doc, 'Excel2007' ); | |
| 263 | - ob_start(); | |
| 264 | - $writer->save( 'php://output' ); | |
| 265 | - $xlsData = ob_get_contents(); | |
| 266 | - ob_end_clean(); | |
| 267 | - } else { | |
| 268 | - do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'Class PHPExcel does not exist!', 'error', __FILE__, __LINE__ ); | |
| 269 | - error_log( 'Class PHPExcel does not exist!' ); | |
| 270 | - } | |
| 255 | + $doc = new PHPExcel(); | |
| 256 | + $doc->getActiveSheet()->fromArray( $rows, null, 'A1' ); | |
| 257 | + $doc->getActiveSheet()->setTitle( $chart ); | |
| 258 | + $doc = apply_filters( 'visualizer_excel_doc', $doc ); | |
| 259 | + $writer = PHPExcel_IOFactory::createWriter( $doc, 'Excel2007' ); | |
| 260 | + ob_start(); | |
| 261 | + $writer->save( 'php://output' ); | |
| 262 | + $xlsData = ob_get_contents(); | |
| 263 | + ob_end_clean(); | |
| 271 | 264 | return array( |
| 272 | 265 | 'csv' => 'data:application/vnd.ms-excel;base64,' . base64_encode( $xlsData ), |
| 273 | 266 | 'name' => $filename, |
| 274 | 267 | ); |