Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPSpreadsheet pie chart with part separated unwantedly #2506

Closed
DabLoan opened this issue Jan 18, 2022 · 0 comments · Fixed by #2928
Closed

PHPSpreadsheet pie chart with part separated unwantedly #2506

DabLoan opened this issue Jan 18, 2022 · 0 comments · Fixed by #2928

Comments

@DabLoan
Copy link

DabLoan commented Jan 18, 2022

This is:

- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

When I use the template with pie charts on it the output shall keep them.

What is the current behavior?

The part in the pie charts in the output are separated :
Expected :
image
Actual output :
image

What are the steps to reproduce?

I take data from a json file and put result in var to fill the cells.
test-template.xlsx

<?php

require __DIR__ . '/vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

$json = file_get_contents("toexcel.json");

$parsed_json = json_decode($json);
$data1 = $parsed_json->{'donneestaxesex'}->{'chaussea'}[0]->{'invariants'}[0]->{'modeoccupation'}[0]->{'DIF'};
$data2 = $parsed_json->{'donneestaxesex'}->{'chaussea'}[0]->{'invariants'}[0]->{'modeoccupation'}[0]->{'INC'};
$data3 = $parsed_json->{'donneestaxesex'}->{'chaussea'}[0]->{'invariants'}[0]->{'modeoccupation'}[0]->{'LNO'};
$data4 = $parsed_json->{'donneestaxesex'}->{'chaussea'}[0]->{'invariants'}[0]->{'modeoccupation'}[0]->{'LOC'};
$data5 = $parsed_json->{'donneestaxesex'}->{'chaussea'}[0]->{'invariants'}[0]->{'typeoccupation'}[0]->{'partielle'};
$data6 = $parsed_json->{'donneestaxesex'}->{'chaussea'}[0]->{'invariants'}[0]->{'typeoccupation'}[0]->{'totale'};

$reader = IOFactory::createReader('Xlsx');
$reader->setIncludeCharts(true);
$spreadsheet = $reader->load('test-template.xlsx');
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('J4', $data1);
$sheet->setCellValue('J8', $data2);
$sheet->setCellValue('J9', $data3);
$sheet->setCellValue('J10', $data4);
$sheet->setCellValue('J13', $data5);
$sheet->setCellValue('J14', $data6);


$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->setIncludeCharts(true);
$writer->save('test-output.xlsx');

Which versions of PhpSpreadsheet and PHP are affected?

PHP 7.4.10.
PHPSpreadsheet using latest version.

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Jul 10, 2022
Fix PHPOffice#2506. Reader only tests if Explosion is set without capturing its value. Writer hard-codes value when it is set.
oleibman added a commit that referenced this issue Jul 14, 2022
Fix #2506. Reader only tests if Explosion is set without capturing its value. Writer hard-codes value when it is set.
MarkBaker added a commit that referenced this issue Jul 18, 2022
### Added

- Add Chart Axis Option textRotation [Issue #2705](#2705) [PR #2940](#2940)

### Changed

- Nothing

### Deprecated

- Nothing

### Removed

- Nothing

### Fixed

- Fix Encoding issue with Html reader (PHP 8.2 deprecation for mb_convert_encoding) [Issue #2942](#2942) [PR #2943](#2943)
- Additional Chart fixes
  - Pie chart with part separated unwantedly [Issue #2506](#2506) [PR #2928](#2928)
  - Chart styling is lost on simple load / save process [Issue #1797](#1797) [Issue #2077](#2077) [PR #2930](#2930)
  - Can't create contour chart (surface 2d) [Issue #2931](#2931) [PR #2933](#2933)
- VLOOKUP Breaks When Array Contains Null Cells [Issue #2934](#2934) [PR #2939](#2939)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant