| @@ -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( sanitize_title( $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 | ); |
| @@ -322,21 +315,5 @@ | ||
| 322 | 315 | 'csv' => $html, |
| 323 | 316 | ); |
| 324 | 317 | } |
| 325 | 318 | |
| 326 | - /** | |
| 327 | - * Returns the language of the locale. | |
| 328 | - * | |
| 329 | - * @access protected | |
| 330 | - */ | |
| 331 | - protected function get_language() { | |
| 332 | - $locale = get_locale(); | |
| 333 | - if ( empty( $locale ) ) { | |
| 334 | - return ''; | |
| 335 | - } | |
| 336 | - $array = explode( '_', $locale ); | |
| 337 | - if ( count( $array ) < 2 ) { | |
| 338 | - return ''; | |
| 339 | - } | |
| 340 | - return reset( $array ); | |
| 341 | - } | |
| 342 | 319 | } |