KoolReport's Forum

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

Pivot excel #914

Open Batouta opened this topic on on Jun 9, 2019 - 7 comments

Batouta commented on Jun 9, 2019

I'm using koolreport 3.1.0 to extract excel data with a pivot and I have the error: A PHP Error was encountered Severity: Notice Message: Undefined index: rowNodesMark

But when i use koolreport 4.0.0 or 4.0.1 i have this error: ErrorException (E_ERROR) Illegal offset type in isset or empty (View:

David Winterburn commented on Jun 10, 2019

Hi Batouta,

Would you please post the full error message for us to investigate the issue for you? Thanks!

Batouta commented on Jun 10, 2019

I use the koolreport_pro_3.1.0 i have this error: ErrorException (E_NOTICE) Undefined index: rowNodesMark

D:\xampp\htdocs\paeij\vendor\koolreport\packages\pivot\PivotExcelExport.php namespace koolreport\pivot;

use \koolreport\core\Utility; use \PhpOffice\PhpSpreadsheet as ps;

class PivotExcelExport {

public function saveDataStoreToSheet($dataStore, $sheet, $option)
{
    $totalName = Utility::get($option, 'totalName', 'Total');
    $emptyValue = Utility::get($option, 'emptyValue', '-');
    $headerMap = Utility::get($option, 'headerMap', array());
    $dataMap = Utility::get($option, 'dataMap', array());
    $meta = $dataStore->meta()['columns'];

    $pivotUtil = new PivotUtil($dataStore, $option);
    $fni = $pivotUtil->getFieldsNodesIndexes();
    $rowNodes = $fni['mappedRowNodes'];
    $rowNodesMark = $fni['rowNodesMark'];
    $rowIndexes = $fni['rowIndexes'];
    $rowFields = array_values($fni['rowFields']);
    $colNodes = $fni['mappedColNodes'];
    $colNodesMark = $fni['colNodesMark'];
    $colIndexes = $fni['colIndexes'];
    $colFields = array_values($fni['colFields']);
    $dataNodes = $fni['dataNodes'];
    $dataFields = array_values($fni['dataFields']);
    $indexToData = $fni['indexToData'];

    $cell = ps\Cell\Coordinate::stringFromColumnIndex(1) . 1;
    $endCell = ps\Cell\Coordinate::stringFromColumnIndex(
        count($rowFields)) . count($colFields);
    $sheet->setCellValue($cell, implode(' | ', $dataNodes));
    $sheet->mergeCells($cell . ":" . $endCell);
    $sheet->getStyle($cell)->getAlignment()->setHorizontal(
        ps\Style\Alignment::HORIZONTAL_CENTER);
    $sheet->getStyle($cell)->getAlignment()->setVertical(
        ps\Style\Alignment::VERTICAL_TOP);

Arguments "Undefined index: rowNodesMark"

This is my code:

pivotindicateur.php

<?php //MyReport.php namespace App\Reports;

require_once dirname(FILE)."/../../vendor/koolreport/autoload.php"; // No need, if you install KoolReport through composer use \koolreport\processes\Group; use \koolreport\cube\processes\Cube; use \koolreport\processes\ColumnMeta; use \koolreport\processes\CopyColumn; use \koolreport\processes\DateTimeFormat; use \koolreport\widgets\google\ColumnChart; use \koolreport\processes\Filter; use \koolreport\pivot\processes\Pivot; use \koolreport\pivot\processes\PivotExtract; use \koolreport\pivot\PivotExcelExport; require_once "BaseRapport.php";

class PivotIndicateur extends BaseRapport {

  use \koolreport\excel\ExcelExportable;

use \koolreport\export\Exportable;

public function setup()
{
    $node=$this->src('test')
    ->query("select LIBEFFT,LIBOUTPUT,LIBELLEIND,count(*) as TOTAL FROM indicateur i
    join effet e on e.IDEFFET=i.IDEFFET
    join output o on o.IDOUTPUT=i.IDOUTPUT group by LIBEFFT,LIBOUTPUT,LIBELLEIND;")
    ->pipe(new ColumnMeta(array(
      'TOTAL'=>array(
        'type'=>'number',
      ),
    )))
    ->pipe(new Pivot(array(
      'dimensions'=>array(
        'row'=>'LIBEFFT,LIBOUTPUT,LIBELLEIND'
      ),
      'aggregates'=>array(
        'sum'=>'TOTAL',
      )
    )))

    ->pipe($this->dataStore('pivotindicateur'));
}  

} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////::::

pivotindicateur.view.php

<?php

use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\ColumnChart;
use \koolreport\widgets\google\BarChart;
use \koolreport\widgets\google\DonutChart;
use \koolreport\widgets\google\PieChart;
use \koolreport\widgets\google\GeoChart;
use \koolreport\drilldown\DrillDown;
use \koolreport\processes\CopyColumn;
use \koolreport\pivot\widgets\PivotTable;

?>

Tableau des indicateurs

dataStore('pivotindicateur'); PivotTable::create(array( 'dataStore'=>$dataStore, 'rowDimension'=>'row', 'measures'=>array( 'TOTAL - sum', ), 'rowSort'=>array( 'TOTAL - sum'=>'desc', ), 'rowCollapseLevels'=>array(0), 'totalName'=>'Total', 'width'=>'100%', )); ?>

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

pivotindicateur.excel.php:

<?php

use \koolreport\excel\Table;
use \koolreport\excel\PivotTable;
use \koolreport\excel\BarChart;
use \koolreport\excel\LineChart;

$sheet1 = "Indicateur";

?>

[ 'name' => 'Calibri', //'Verdana', 'Arial' 'size' => 30, 'bold' => false, 'italic' => FALSE, 'underline' => 'none', //'double', 'doubleAccounting', 'single', 'singleAccounting' 'strikethrough' => FALSE, 'superscript' => false, 'subscript' => false, 'color' => [ 'rgb' => '000000', 'argb' => 'FF000000', ] ], 'alignment' => [ 'horizontal' => 'general',//left, right, center, centerContinuous, justify, fill, distributed 'vertical' => 'bottom',//top, center, justify, distributed 'textRotation' => 0, 'wrapText' => false, 'shrinkToFit' => false, 'indent' => 0, 'readOrder' => 0, ], 'borders' => [ 'top' => [ 'borderStyle' => 'none', //dashDot, dashDotDot, dashed, dotted, double, hair, medium, mediumDashDot, mediumDashDotDot, mediumDashed, slantDashDot, thick, thin 'color' => [ 'rgb' => '808080', 'argb' => 'FF808080', ] ], //left, right, bottom, diagonal, allBorders, outline, inside, vertical, horizontal ], 'fill' => [ 'fillType' => 'none', //'solid', 'linear', 'path', 'darkDown', 'darkGray', 'darkGrid', 'darkHorizontal', 'darkTrellis', 'darkUp', 'darkVertical', 'gray0625', 'gray125', 'lightDown', 'lightGray', 'lightGrid', 'lightHorizontal', 'lightTrellis', 'lightUp', 'lightVertical', 'mediumGray' 'rotation' => 90, 'color' => [ 'rgb' => 'A0A0A0', 'argb' => 'FFA0A0A0', ], 'startColor' => [ 'rgb' => 'A0A0A0', 'argb' => 'FFA0A0A0', ], 'endColor' => [ 'argb' => 'FFFFFF', 'argb' => 'FFFFFFFF', ], ], ]; ?>
Sales Report
'pivotindicateur', )); ?>
Now i when i try to use koolreport_pro4.1.0, the pivot table is not displayed and i have this error But when i use koolreport 4.0.0 or 4.0.1 i have this error: ErrorException (E_ERROR) Illegal offset type in isset or empty (View: D:\xampp\htdocs\paeij\resources\views\report.blade.php) D:\xampp\htdocs\paeij\vendor\koolreport\src\core\Utility.php if (is_array($keys) and count($keys) > 0) { foreach ($keys as $key) { $arr = self::get($arr, $key, $default); } return $arr; } if (is_string($keys) || is_int($keys)) { return isset($arr[$keys]) ? $arr[$keys] : $default; } return $default; } /** * Init an key value inside an array * @param array $arr The array * @param string $key The key * @param mixed $default The default value to fill if key is not found * @return array The array */ static function init(&$arr, $key, $default = null) { if (! isset($arr[$key])) $arr[$key] = $default; return $arr[$key]; } /** * Get array if the value inside an array is a string * * @param array $arr The array * @param string $key The key * @param mixed $default The default value * @param array Return the value in array format */ static function getArray($arr,$key,$default=array()) { $value = Utility::get($arr,$key); return ($value!=null)?explode(',', $value):$default; } /** * Get only some of the keys from an array Arguments "Illegal offset type in isset or empty (View: D:\xampp\htdocs\paeij\resources\views\report.blade.php)" Thank you.
David Winterburn commented on Jun 11, 2019

Hi Batouta,

It's very hard to read your post. Would you please post the screenshot of the error message? Thanks!

Batouta commented on Jun 11, 2019

Hi David. Ok.

David Winterburn commented on Jun 11, 2019

Hi Batouta,

I think this is the error with a previous version of Pivot. Would you please update to a newer version of Pivot and send me screenshot if there's any error message. Thanks!

Batouta commented on Jun 11, 2019

Ok! I replaced the old pivot package with that of version 4.0.1 and i have this error( the pivot table is no longer displayed.

David Winterburn commented on Jun 12, 2019

Hi Batouta,

It looks like you're using an older version of KoolReport Core. Please try either updating Core to a newer version or at least replacing the file Utility.php with a newer version. Then let us know if there's still any problem. 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