2

i have my exported excel using phpspreadsheet contain chart works good on libre office, but have blank area chart when i open using MS. Excel.

The problem is, data range i use to build chart is hidden using this code.

$spreadsheet->getActiveSheet()->getRowDimension($rowNow)->setVisible(false);

but this can be done with setting on MS. excel like this. enter image description here

and i use this code to build chart:

//  Build the dataseries
    $series = new PhpOffice\PhpSpreadsheet\Chart\DataSeries(
        PhpOffice\PhpSpreadsheet\Chart\DataSeries::TYPE_PIECHART, // plotType
        NULL, // plotGrouping
        range(0, count($dataSeriesValues) - 1), // plotOrder
        $dataSeriesLabels, // plotLabel
        $xAxisTickValues, // plotCategory
        $dataSeriesValues        // plotValues
    );
    //  Set the series in the plot area
    $plotArea = new PhpOffice\PhpSpreadsheet\Chart\PlotArea(null, [$series]);
    $legend = new PhpOffice\PhpSpreadsheet\Chart\Legend(PhpOffice\PhpSpreadsheet\Chart\Legend::POSITION_RIGHT, null, false);
    $title = new PhpOffice\PhpSpreadsheet\Chart\Title($t);
    $yAxisLabel = new PhpOffice\PhpSpreadsheet\Chart\Title('Value');
    // create chart
    $chart = new PhpOffice\PhpSpreadsheet\Chart\Chart(
        'chart1', // name
        $title, // title
        $legend, // legend
        $plotArea, // plotArea
        true, // plotVisibleOnly
        0, // displayBlanksAs
        null, // xAxisLabel
        $yAxisLabel  // yAxisLabel
    );

    $chart->setTopLeftPosition($pos[0]);
    $chart->setBottomRightPosition($pos[1]);

What attribute i should add to my chart builder to represent the setting i provide before?

Panda
  • 6,955
  • 6
  • 40
  • 55
Ryan Arief
  • 983
  • 2
  • 16
  • 36

0 Answers0