Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support for Google Sheets Exported XLSX Charts Google Sheets XLSX charts use oneCellAnchor positioning and the data series do not have the *Cache elements with cached values. * update CHANGELOG * Add support for Google Sheets Exported XLSX Charts Google Sheets XLSX charts use oneCellAnchor positioning and the data series do not have the *Cache elements with cached values. Because the reader had been assuming *Cache elements existed as children of strRef and numRef, errors about the node being deleted were thrown when reading Xlsx exported from Google Sheets. Co-authored-by: Darren Maczka <dkm@utk.edu>
- Loading branch information
1 parent
304904d
commit 44248cd
Showing
5 changed files
with
107 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Reader; | ||
|
||
use PhpOffice\PhpSpreadsheet\Chart\DataSeries; | ||
use PhpOffice\PhpSpreadsheet\IOFactory; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class SheetsXlsxChartTest extends TestCase | ||
{ | ||
public function testLoadSheetsXlsxChart(): void | ||
{ | ||
$filename = 'tests/data/Reader/XLSX/sheetsChartsTest.xlsx'; | ||
$reader = IOFactory::createReader('Xlsx')->setIncludeCharts(true); | ||
$spreadsheet = $reader->load($filename); | ||
$worksheet = $spreadsheet->getActiveSheet(); | ||
|
||
$charts = $worksheet->getChartCollection(); | ||
self::assertEquals(2, $worksheet->getChartCount()); | ||
self::assertCount(2, $charts); | ||
|
||
$chart1 = $charts[0]; | ||
$pa1 = $chart1->getPlotArea(); | ||
self::assertEquals(2, $pa1->getPlotSeriesCount()); | ||
|
||
$pg1 = $pa1->getPlotGroup()[0]; | ||
|
||
self::assertEquals(DataSeries::TYPE_LINECHART, $pg1->getPlotType()); | ||
self::assertCount(2, $pg1->getPlotLabels()); | ||
self::assertCount(2, $pg1->getPlotValues()); | ||
self::assertCount(2, $pg1->getPlotCategories()); | ||
|
||
$chart2 = $charts[1]; | ||
$pa1 = $chart2->getPlotArea(); | ||
self::assertEquals(2, $pa1->getPlotSeriesCount()); | ||
|
||
$pg1 = $pa1->getPlotGroupByIndex(0); | ||
//Before a refresh, data values are empty | ||
foreach ($pg1->getPlotValues() as $dv) { | ||
self::assertEmpty($dv->getPointCount()); | ||
} | ||
$pg1->refresh($worksheet); | ||
foreach ($pg1->getPlotValues() as $dv) { | ||
self::assertEquals(9, $dv->getPointCount()); | ||
} | ||
self::assertEquals(DataSeries::TYPE_SCATTERCHART, $pg1->getPlotType()); | ||
self::assertCount(2, $pg1->getPlotLabels()); | ||
self::assertCount(2, $pg1->getPlotValues()); | ||
self::assertCount(2, $pg1->getPlotCategories()); | ||
} | ||
} |
Binary file not shown.