KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Excel export issues #1651

Open Daniel Amamoo-Otchere opened this topic on on Oct 6, 2020 - 4 comments

Daniel Amamoo-Otchere commented on Oct 6, 2020

Hello Kool team, I have an issue exporting to excel. The system will download alright but each time you open it it gives the following error.

This error appears even for Microsoft excel, sometimes you are able to fix the error but recently it just does not allow one to fix the error. I am highly frustrated.

Can you offer some assistance.

This is the code

	require_once "PaymentExcel.php";
					$call_id =$_GET['call_id'];
			      	$report = new PaymentExcel(
					array(
					     "call_id"=>$call_id	
					));
					$report->run()
					->exportToExcel(       
						array(						 
							"dataStores" => array(
								'get_data'=>array(
								 "columns"=>array(0,1
								)))
				 ))->toBrowser("PaymentExcel_".date("d_m_Y").".xlsx",false);
David Winterburn commented on Oct 7, 2020

Hi Daniel,

Would you please let us know which version of Excel package you are using? Thanks!

Daniel Amamoo-Otchere commented on Oct 9, 2020

I have version KoolReport Pro 4.3.2.

Daniel Amamoo-Otchere commented on Oct 9, 2020

The interesting thing is that I have implemented it on a report before and it works ok but same thing does not work on another report despite having same format.

David Winterburn commented on Oct 12, 2020

Hi Daniel,

There was some chart compatibility issue with the PHPSpreadsheet library with some versions of MS Excel. The latest version of KoolReport Pro or Excel package fixed this. If you don't want to update please try a fix like this: open the file kooreport/excel/Chart.php and replace the following:

		$chart = new PHPOfficeChart(
            $chartName, // name
            $title, // title
            $legend, // legend
            $plotArea, // plotArea
            true, // plotVisibleOnly
            0, // displayBlanksAs
            $xAxisLabel, // xAxisLabel
            $yAxisLabel  // yAxisLabel
        );

with this:

		$yaxis = new Axis();
        // $xaxis->setAxisOptionsProperties('low', 0, 'autoZero', null, 'in', 'out', 0, 40, 5, 0);
        $yaxis->setAxisOptionsProperties(
            Util::get($content, ['yAxis', 'axis_labels'], 'nextTo'),
            Util::get($content, ['yAxis', 'horizontal_crosses_value']),
            Util::get($content, ['yAxis', 'horizontal_crosses']),
            Util::get($content, ['yAxis', 'axis_orientation']),
            Util::get($content, ['yAxis', 'major_tmt']),
            Util::get($content, ['yAxis', 'minor_tmt']),
            Util::get($content, ['yAxis', 'minimum']),
            Util::get($content, ['yAxis', 'maximum']),
            Util::get($content, ['yAxis', 'major_unit']),
            Util::get($content, ['yAxis', 'minor_unit'])
        );
        $xaxis = new Axis();
        $xaxis->setAxisOptionsProperties(
            Util::get($content, ['xAxis', 'axis_labels'], 'nextTo'),
            Util::get($content, ['xAxis', 'horizontal_crosses_value']),
            Util::get($content, ['xAxis', 'horizontal_crosses']),
            Util::get($content, ['xAxis', 'axis_orientation']),
            Util::get($content, ['xAxis', 'major_tmt']),
            Util::get($content, ['xAxis', 'minor_tmt']),
            Util::get($content, ['xAxis', 'minimum']),
            Util::get($content, ['xAxis', 'maximum']),
            Util::get($content, ['xAxis', 'major_unit']),
            Util::get($content, ['xAxis', 'minor_unit'])
        );

        //	Create the chart
        $chartName = Util::get($content, 'name', 'chart_' . $sheetInfo['chartAutoId']++);
        $chart = new PHPOfficeChart(
            $chartName, // name
            $title, // title
            $legend, // legend
            $plotArea, // plotArea
            true, // plotVisibleOnly
            'gap', //0, // displayBlanksAs
            $xAxisLabel, // xAxisLabel
            $yAxisLabel,  // yAxisLabel
            $yaxis,
            $xaxis
        );

Please try this and let us know how it works for you. Thanks!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None