| @@ -145,13 +145,13 @@ | ||
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | 147 | * Extracts the data for a chart and prepares it for the given type. |
| 148 | 148 | * |
| 149 | - * @access public | |
| 149 | + * @access protected | |
| 150 | 150 | * @param int $chart_id The chart id. |
| 151 | 151 | * @param string $type The exported type. |
| 152 | 152 | */ |
| 153 | - public function _getDataAs( $chart_id, $type ) { | |
| 153 | + protected function _getDataAs( $chart_id, $type ) { | |
| 154 | 154 | $final = null; |
| 155 | 155 | $success = false; |
| 156 | 156 | if ( $chart_id ) { |
| 157 | 157 | $chart = get_post( $chart_id ); |
| @@ -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 | ); |