The attached spreadsheet has a chart with two Y axis. I want to retrieve both Y axis labels. I can retrieve the data/series for both Y axis.
Only one Y axis label is retrieved (far-right Y axis label). This is the output:
PhpOffice\PhpSpreadsheet\Chart\Title::__set_state(array(
'caption' =>
array (
0 =>
PhpOffice\PhpSpreadsheet\RichText::__set_state(array(
'richTextElements' =>
array (
0 =>
PhpOffice\PhpSpreadsheet\RichText\Run::__set_state(array(
'font' =>
PhpOffice\PhpSpreadsheet\Style\Font::__set_state(array(
'name' => 'Calibri',
'size' => 11,
'bold' => false,
'italic' => false,
'superScript' => false,
'subScript' => false,
'underline' => 'none',
'strikethrough' => false,
'color' =>
PhpOffice\PhpSpreadsheet\Style\Color::__set_state(array(
'argb' => 'FF000000',
'parentPropertyName' => NULL,
'isSupervisor' => false,
'parent' => NULL,
)),
'isSupervisor' => false,
'parent' => NULL,
)),
'text' => 'Percentage',
)),
),
)),
),
'layout' => NULL,
))
Attached is the exact spreadsheet and the code to reproduce.
<?php
require __DIR__ . '/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\IOFactory;
$sheetnames = array('#5 output');
$reader = IOFactory::createReaderForFile("test.xlsx");
$reader->setIncludeCharts(true);
$reader->setLoadSheetsOnly($sheetnames);
$spreadsheet = $reader->load("test.xlsx");
foreach ($spreadsheet->getWorksheetIterator() as $worksheet) {
$sheetName = $worksheet->getTitle();
$chartNames = $worksheet->getChartNames();
if (empty($chartNames)) {
throw new \Exception('No charts found!');
}
\natsort($chartNames);
foreach ($chartNames as $i => $chartName) {
$chart = $worksheet->getChartByName($chartName);
\var_dump($chart->getYAxisLabel());
}
}
$spreadsheet->disconnectWorksheets();
unset($spreadsheet);
PhpSpreadsheet: 1.0.0-beta
php --version
PHP 5.6.25 (cli) (built: Oct 21 2016 17:57:17)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
I have found the bug where it happened, wait me for fixing it tomorrow.
Hello, I have solved this problem, you can check if the code is directly right.
Awesome! I can confirm that the fix worked, here's my output
array (
0 =>
PhpOffice\PhpSpreadsheet\Chart\Title::__set_state(array(
'caption' =>
array (
0 =>
PhpOffice\PhpSpreadsheet\RichText::__set_state(array(
'richTextElements' =>
array (
0 =>
PhpOffice\PhpSpreadsheet\RichText\Run::__set_state(array(
'font' =>
PhpOffice\PhpSpreadsheet\Style\Font::__set_state(array(
'name' => 'Calibri',
'size' => 11,
'bold' => false,
'italic' => false,
'superScript' => false,
'subScript' => false,
'underline' => 'none',
'strikethrough' => false,
'color' =>
PhpOffice\PhpSpreadsheet\Style\Color::__set_state(array(
'argb' => 'FF000000',
'parentPropertyName' => NULL,
'isSupervisor' => false,
'parent' => NULL,
)),
'isSupervisor' => false,
'parent' => NULL,
)),
'text' => 'Tonnes',
)),
),
)),
),
'layout' => NULL,
)),
1 =>
PhpOffice\PhpSpreadsheet\Chart\Title::__set_state(array(
'caption' =>
array (
0 =>
PhpOffice\PhpSpreadsheet\RichText::__set_state(array(
'richTextElements' =>
array (
0 =>
PhpOffice\PhpSpreadsheet\RichText\Run::__set_state(array(
'font' =>
PhpOffice\PhpSpreadsheet\Style\Font::__set_state(array(
'name' => 'Calibri',
'size' => 11,
'bold' => false,
'italic' => false,
'superScript' => false,
'subScript' => false,
'underline' => 'none',
'strikethrough' => false,
'color' =>
PhpOffice\PhpSpreadsheet\Style\Color::__set_state(array(
'argb' => 'FF000000',
'parentPropertyName' => NULL,
'isSupervisor' => false,
'parent' => NULL,
)),
'isSupervisor' => false,
'parent' => NULL,
)),
'text' => 'Percentage',
)),
),
)),
),
'layout' => NULL,
)),
)
Can this be pushed to the main repo? How long does that normally take?
@treadmillian The reader is fixed correct, but I forgot to fix the writer, wait me to fix it tomorrow, and your another problem #203 also need wait to tomorrow or the day after tomorrow, because I am so busy in working, weekends may be a good time.
@GreatHumorist No problem, thank you for looking at the issue so quickly, much appreciated.
@GreatHumorist any update on this issue?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.
Most helpful comment
I have found the bug where it happened, wait me for fixing it tomorrow.