KoolReport's Forum

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

"array_keys() expects parameter 1 to be array, null given" #1100

Closed paulo opened this topic on on Sep 25, 2019 - 8 comments

paulo commented on Sep 25, 2019

I'm getting the following error when exporting a report. However, I am able to see the report on the screen without any issue. I am able to export other reports. What can I do to fix this issue? Thank you

/home/forge/dev.ellisontravel.com/vendor/koolreport/excel/ExportHandler.php

public function dataStore($name)
{
    return $this->report->dataStore($name);
}

protected function getDataStoreType($dataStore) {
    if (! $dataStore) {
        return 'table';
    }
    if (is_string($dataStore)) {
        return 'table';
    } elseif (is_array($dataStore)) {
        $meta = Util::get($dataStore, ['meta', 'columns'], []);
        $row = Util::get($dataStore, ['data', 0], []);
    } else {
        $meta = $dataStore->meta()['columns'];
        $dataStore->popStart();
        $row = $dataStore->pop();
    }
    $colNames = array_keys($row);
    foreach ($colNames as $colName) {
        $type = Util::get($meta, [$colName, 'type'], '');
        if ($type === 'dimension')
            return 'pivottable';
    }
    return 'table';
}

protected function getExportObject($type) {
    $export;
    switch ($type) {
        case 'table':
            $export = '\koolreport\excel\Table';
            break;
        case 'chart':
            $export = '\koolreport\excel\Chart';
            break;
        case 'pivottable':
            $export = '\koolreport\excel\PivotTable';
            break;

Arguments "array_keys() expects parameter 1 to be array, null given"

KoolReport commented on Sep 26, 2019

One question: is your data empty?

David Winterburn commented on Sep 26, 2019

Hi Paulo,

For now please replace this line:

$colNames = array_keys($row);

with:

$colNames = ! empty($row) ? array_keys($row) : [];

We will apply a fix for your case in the next release of Excel package. Thanks for your feedback!

paulo commented on Sep 26, 2019

One of the results is empty in some cases because only list records assigned to an employee. So, if the employee has no records, it won't list anything. Thank you for fixing the issue! Paulo

paulo commented on Jan 13, 2020

did this get fixed? thank you

David Winterburn commented on Jan 14, 2020

Hi Paulo,

This bug has been fixed in the latest version of the Excel package. Let us know if any issue remains. Thanks!

paulo commented on Feb 4, 2020

Hi, the issue is still happening - please take a look

I'm updating via composer composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader composer update --lock --no-dev --with-dependencies

Here is my composer in production: "koolreport/blade": "*",

    "koolreport/core": "^4.0",
    "koolreport/export": "*",
    "koolreport/excel":"*",
    "koolreport/pro": "*",

array_keys() expects parameter 1 to be array, null given {"userId":3,"exception":"[object] (ErrorException(code: 0): array_keys() expects parameter 1 to be array, null given at /home/forge/my.ellisontravel.com/vendor/koolreport/excel/ExportHandler.php:72) [stacktrace] #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'array_keys() ex...', '/home/forge/my....', 72, Array) #1 /home/forge/my.ellisontravel.com/vendor/koolreport/excel/ExportHandler.php(72): array_keys(NULL) #2 /home/forge/my.ellisontravel.com/vendor/koolreport/excel/ExportHandler.php(258): koolreport\excel\ExportHandler->getDataStoreType(Object(koolreport\core\DataStore)) #3 /home/forge/my.ellisontravel.com/vendor/koolreport/excel/ExcelExportable.php(39): koolreport\excel\ExportHandler->exportToExcel(Array) #4 /home/forge/my.ellisontravel.com/app/Http/Controllers/Admin/AdminReportController.php(347): App\Reports\Managers\EarnedCommissionDetailsbyPlannerReport->exportToExcel() #5 [internal function]: App\Http\Controllers\Admin\AdminReportController->executeReport('Reporting:Earne...') #6 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array) #7 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('executeReport', Array) #8 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\Admin\AdminReportController), 'executeReport') #9 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\Routing\Route->runController() #10 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(680): Illuminate\Routing\Route->run() #11 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #12 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #13 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure)) #14 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #15 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(75): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #16 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure)) #17 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #18 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #19 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #20 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #21 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #22 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #23 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #24 /home/forge/my.ellisontravel.com/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))

paulo commented on Feb 4, 2020

Hi Dave, do you require any more info about this issue ?thanks

KoolReport commented on Feb 4, 2020

We have just release the KoolReport Pro 4.5.1 with updated Excel 7.1.1. Could you please upgrade.

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
bug
solved

Export