PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.1.3
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.1.3
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | classes/Visualizer/Module.php +11 -6 3.1.03.1.3 View file →
@@ -252,26 +252,31 @@
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 does not like sheet names longer than 31 characters.
256 + // PHPExcel did not like sheet names longer than 31 characters and we will assume the same with PhpSpreadsheet
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 +
260 265 $xlsData = '';
261 - if ( class_exists( 'PHPExcel' ) ) {
262 - $doc = new PHPExcel();
266 + if ( class_exists( 'PhpOffice\PhpSpreadsheet\Spreadsheet' ) ) {
267 + $doc = new PhpOffice\PhpSpreadsheet\Spreadsheet();
263 268 $doc->getActiveSheet()->fromArray( $rows, null, 'A1' );
264 269 $doc->getActiveSheet()->setTitle( sanitize_title( $chart ) );
265 270 $doc = apply_filters( 'visualizer_excel_doc', $doc );
266 - $writer = PHPExcel_IOFactory::createWriter( $doc, 'Excel2007' );
271 + $writer = PhpOffice\PhpSpreadsheet\IOFactory::createWriter( $doc, 'Xlsx' );
267 272 ob_start();
268 273 $writer->save( 'php://output' );
269 274 $xlsData = ob_get_contents();
270 275 ob_end_clean();
271 276 } else {
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!' );
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!' );
274 279 }
275 280 return array(
276 281 'csv' => 'data:application/vnd.ms-excel;base64,' . base64_encode( $xlsData ),
277 282 'name' => $filename,