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

Charts are broken / doesn't validate against Office 2013 XML #382

Closed
simplyray opened this issue Jul 11, 2017 · 37 comments
Closed

Charts are broken / doesn't validate against Office 2013 XML #382

simplyray opened this issue Jul 11, 2017 · 37 comments

Comments

@simplyray
Copy link

I'm using the latest 0.9.0 release but the file generated from the Sample_05_Chart.php is broken and Powerpoint 2016 needs to repair the file before opening it (which removes the charts completly).

Sample_05_Chart.pptx

I've tried to validate the generated *.pptx file against Office 2013 XML formats and it throws 218 errors. Seems like every value for the attribute 'val' is a string having a percentage sign behind it instead of Int32

@Progi1984 Progi1984 self-assigned this Jul 11, 2017
@Progi1984 Progi1984 added this to the 0.10.0 milestone Jul 11, 2017
@Progi1984
Copy link
Member

@simplyray Thanks for the issue.

Where can i find the xsd for validating pptx file against Office 2013 XML formats ? (And may be Office 2007 & 2010)

@simplyray
Copy link
Author

simplyray commented Jul 11, 2017

@Progi1984 I've used the Open XML SDK Tool from Microsoft. It also includes validation for 2007 and 2010)

validation

@Progi1984
Copy link
Member

Todo :

Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Aug 5, 2017
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Aug 6, 2017
@Progi1984
Copy link
Member

PR relative to this issue : #390

Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Aug 8, 2017
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Aug 8, 2017
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Aug 18, 2017
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Aug 18, 2017
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Sep 13, 2017
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Sep 13, 2017
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Sep 13, 2017
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Sep 13, 2017
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Sep 13, 2017
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Sep 15, 2017
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Sep 15, 2017
@larryb-redflare
Copy link

See comment on #353
PhpPresentation\Writer\PowerPoint2007\PptCharts Line 102 outputs a % which cause invalid XML

$objWriter->writeElementIf($hPercent != null, 'c:hPercent', 'val', $hPercent . '%');

@dlollman
Copy link

@Progi1984 Do you know when this fix will be released?

Currently unable to do any bar charts without ppt being broken and need repairing (but no chart showing up).

Happy to test in any way I can.

@Progi1984
Copy link
Member

@dlollman You can test this branch and give your feedback.

@dlollman
Copy link

dlollman commented Nov 21, 2017

@Progi1984 Thanks, no good for that branch for me. Using Powerpoint for mac (microsoft). Relevant code I am using to test this out:

$current_slide++;
    // Slide 5 (REDACTED)
    // Create slide
    ////echo date('H:i:s') . ' Create slide '.$current_slide.EOL;
    $slides[$current_slide] = $objPHPPresentation->createSlide();
    $slides[$current_slide]->setName('REDACTED');
    $slides[$current_slide]->setBackground($oBkgImageSlide);

    $richtext = $slides[$current_slide]->createRichTextShape()
            ->setHeight($slide_style["data_slide"]["dimensions"]["height"])
            ->setWidth($slide_style["data_slide"]["dimensions"]["width"])
            ->setOffsetX($slide_style["data_slide"]["dimensions"]["offsetx"])
            ->setOffsetY($slide_style["data_slide"]["dimensions"]["offsety"]);
    $textRun = $richtext->createTextRun('REDACTED');
    $textRun->getFont()->setSize($slide_style["data_slide"]["font"]["size"])
                        ->setItalic($slide_style["data_slide"]["font"]["italic"])
                        ->setColor(new Color($slide_style["data_slide"]["font"]["color"]));
    //add bar chart
    $oFill = new Fill();
    $oFill->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFE06B20'));
    $oShadow = new Shadow();
    $oShadow->setVisible(true)->setDirection(45)->setDistance(10);
    $series1Data = array('Jan' => 133, 'Feb' => 99, 'Mar' => 191, 'Apr' => 205, 'May' => 167, 'Jun' => 201, 'Jul' => 240, 'Aug' => 226, 'Sep' => 255, 'Oct' => 264, 'Nov' => 283, 'Dec' => 293);
    $series2Data = array('Jan' => 266, 'Feb' => 198, 'Mar' => 271, 'Apr' => 305, 'May' => 267, 'Jun' => 301, 'Jul' => 340, 'Aug' => 326, 'Sep' => 344, 'Oct' => 364, 'Nov' => 383, 'Dec' => 379);
    // Create a bar chart (that should be inserted in a shape)
    echo date('H:i:s') . ' Create a bar chart (that should be inserted in a chart shape)'.EOL;
    $barChart = new Bar();
    $barChart->setGapWidthPercent(158);
    $series1 = new Series('2009', $series1Data);
    $series1->setShowSeriesName(true);
    $series1->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new StyleColor('FF4F81BD'));
    $series1->getFont()->getColor()->setRGB('00FF00');
    $series1->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new StyleColor('FFE06B20'));
    $series2 = new Series('2010', $series2Data);
    $series2->setShowSeriesName(true);
    $series2->getFont()->getColor()->setRGB('FF0000');
    $series2->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new StyleColor('FFC0504D'));
    $series2->setLabelPosition(Series::LABEL_INSIDEEND);
    $barChart->addSeries($series1);
    $barChart->addSeries($series2);
    // Create a shape (chart)
    echo date('H:i:s') . ' Create a shape (chart)'.EOL;
    $shape = $slides[$current_slide]->createChartShape();
    $shape->setName('PHPPresentation Monthly Downloads')
        ->setResizeProportional(false)
        ->setHeight(550)
        ->setWidth(700)
        ->setOffsetX(120)
        ->setOffsetY(80);
    $shape->setShadow($oShadow);
    $shape->setFill($oFill);
    $shape->getBorder()->setLineStyle(Border::LINE_SINGLE);
    $shape->getTitle()->setText('PHPPresentation Monthly Downloads');
    $shape->getTitle()->getFont()->setItalic(true);
    $shape->getTitle()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT);
    $shape->getPlotArea()->getAxisX()->setTitle('Month');
    $shape->getPlotArea()->getAxisY()->getFont()->getColor()->setRGB('00FF00');
    $shape->getPlotArea()->getAxisY()->setTitle('Downloads');
    $shape->getPlotArea()->setType($barChart);
    $shape->getLegend()->getBorder()->setLineStyle(Border::LINE_SINGLE);
    $shape->getLegend()->getFont()->setItalic(true);

Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Nov 23, 2017
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue Nov 28, 2017
@dlollman
Copy link

dlollman commented Jan 9, 2018

@Progi1984 is there anything else I can try here to help out?

@Progi1984
Copy link
Member

@dlollman You can help to fix this comment #382#issuecomment-346697422

@dlollman
Copy link

dlollman commented Jan 9, 2018

@Progi1984 That comment has a commit referencing a change for sample 20 which seems to not have any bearing on sample 5 (charts), can you confirm what you want me to do?

Thanks so much

Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue May 24, 2019
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue May 24, 2019
@Progi1984
Copy link
Member

I may have fixed this file for PowerPoint2007 files... I must check each rendering in Office.

Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue May 28, 2019
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue May 28, 2019
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue May 28, 2019
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue May 28, 2019
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue May 28, 2019
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue May 29, 2019
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue May 29, 2019
…ert::assertFileExists() must be of the type string, null given
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue May 29, 2019
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue May 29, 2019
…tion\Tests\Style\AlignmentTest::setExpectedException()
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue May 29, 2019
Progi1984 added a commit to Progi1984/PHPPresentation that referenced this issue May 29, 2019
Progi1984 added a commit that referenced this issue Jun 9, 2019
#382 : Validation for Powerpoint2007 & OpenDocument
@Progi1984
Copy link
Member

@Zetkolink @pcholewa From #507
@mhasanshahid From #505
@dlollman @amitrajput92 @larryb-redflare From #353

Hi here, The PR has been finally fixed... Could you test on develop branch and give me some feedback ?

@JavierDelSolar
Copy link

Hi, im trying to create charts, i have the same problem... somebody can?

@CarmenR13
Copy link

Hi, I´m using the develop branch to run Sample_05_Chart but the Stacked Bar and the Stacked Percentage Bar charts are removed from the resulting pptx file.

I'm getting the following errors:

image

Any help?

polidog pushed a commit to polidog/PHPPresentation that referenced this issue Oct 14, 2019
* Fix. Text is subscripted when set superscript to false

Reset the subscript to false only when superscript is true
Reset the superscript to false only when subscript is true
Update Testcases

* Fix. Some coding style issues

* Fix. Use space insteadof tab

* Remove temp file

tempnam() creates a file that is not removed. Only $pFilename . '.xlsx' is removed by $this->writeSpreadsheet().

* PHP 5.3 is not supported anymore by Travis CI : https://docs.travis-ci.com/user/languages/php/

* PHPOffice#382 : Improve tests for validating the OOXML Schema

* PHPOffice#382 : Validation for Open XML

* PHPOffice#382 : Validation for Open XML

* PHPOffice#382 : Validation for OpenDocument

* PHPOffice#382 : OpenXML (ISO 29500-1 Strict)

* PHPOffice#382 : OpenXML (ISO 29500-1 Strict)

* FIXED : Missing argument 1 for phpDocumentor\Descriptor\Collection::get()

* PHPOffice#360 : Changelog

* PHPOffice#397 : PowerPoint2007 Reader : Background Color based on SchemeColor

* PHPOffice#355 : Doughnut Chart

* PHPOffice#355 : Doughnut Chart (Changelog & Tests & WIP ODPresentation)

* PHPOffice#355 :
- ODPresentation Writer : Doughnut Chart
- ODPresentation Writer : Support for the position of Legend

* PHPOffice#355 : Fix PHPCS

* PHPOffice#355 : Array to string conversion (PHPPresentation/src/PhpPresentation/Writer/PowerPoint2007/LayoutPack/TemplateBased.php:73)

* PHPOffice#355 : PHP 7.1 is now supported

* PHPOffice#370 : PhpOffice\PhpPresentation\Style\Color : Define only the transparency

* PHPOffice#370 : PowerPoint2007 Writer : Support for fill for transparent image

* PHPOffice#370 : ODPresentation Writer : Support for fill for transparent image

* PHPOffice#370 : ODPresentation Reader : Support for fill for image

* PHPOffice#370 : PowerPoint2007 Reader : Support for fill for image

* PHPOffice#382 : PowerPoint2007 Writer (Validation)

* PHPOffice#382 : Replacement PHPDoc (return self => return )

* PHPOffice#382 : Replacement (rand => mt_rand)

* PHPOffice#382 : ODPresentation Writer (Validation)

*  PHPOffice#382 : ODPresentation Writer (Validation)

* PHPOffice#382 : PHPCS Fixes

* PHPOffice#382 : PHPUnit fixes (PHP 5.4)

* refactoring and reducing cyclomatic complexity

* remove extra space

* adding new line at the end of the file

* Use PHPUnit\Framework\TestCase instead of PHPUnit_Framework_TestCase

* PHPOffice#382 : Fixes nefore merge

* PHPOffice#382 : Fixes Sample 20

* problems accessing files

the casing didn't match the case of the folder names.
the vendor autoload is in a different folder...

* Update Sample_Header.php

* Update Sample_Header.php

* Update Sample_Header.php

* Update Sample_Header.php

added some checks to make sure that the sample outputs are set up correctly.

* Update Sample_Header.php

more checks to make sure the sample code can run

* Fixes some CS

* Refactoring tests

* Trailing whitespaces

Signed-off-by: Gabriel Caruso <[email protected]>

* Remove extra lines

Signed-off-by: Gabriel Caruso <[email protected]>

* Simplify return

* Change group shape extents to reflect content width/height.

Previously the group extents where calculated based on the extents of
the containing shapes using the slide/container of the group as the
point of reference. This would result in the group being larger than
needed; especially noticable for a large X or Y offest.

* Remove % signs from PptCharts to fix chart generation. Fixes PHPOffice#452

* Solve Problems with png transparencies

* Update .travis.yml

* Use proper name for `ext-gd`

`ext-gd2` is  not recognized by composer and should instead be `ext-gd`.

* Create auto_assign.yml

* Fix PHP Docs

* Fix Regression PHP Docs int->float

* Fix double aray in PHPDocs
Fix Typing

* Update .travis.yml

* FIXED : Validation of the composer.json

* PHPOffice#382 Update Composer

* PHPOffice#382 : Fixes ECMA-376

*  PHPOffice#382 : Fixes ECMA-376

*  PHPOffice#382 : Fixes OpenDocument

* PHPOffice#382 : Fixes OpenDocument

* Update composer.json

* Update composer.json

* Composer : PHPUnit

* PHPOffice#382 : Remove options not compatible with latest phpunit version

* PHPOffice#382 : TypeError: Argument 2 passed to PHPUnit\Framework\Assert::assertFileExists() must be of the type string, null given

* PHPOffice#382 : The each() function is deprecated. This message will be suppressed on further calls

* PHPOffice#382 : Error: Call to undefined method PhpOffice\PhpPresentation\Tests\Style\AlignmentTest::setExpectedException()

* PHPOffice#382 : PHPCS Fixes

* PHPOffice#382 : PHPDoc : PHP Fatal error:  Uncaught Doctrine\Common\Annotations\AnnotationException

* PHPOffice#540 : Disable documentation

* PHPOffice#540 : Disable documentation

* fix other image mime type

* Drop the support for HHVM

* Add support for image hyperlinks

* Update CHANGELOD.md

* Display hyperlink properties of Drawing\Gd shape
@AlexanderKulia
Copy link

AlexanderKulia commented Oct 25, 2019

Hi, is there any way to make charts work? I tried creating a few, but I always get "Repairment needed" message. Interestingly enough, in Sample_05_Chart two slides are actually created: a 3D pie chart and a non-3D pie chart, other slides are blank. Any idea why?

@MehdiAroui
Copy link

@dsjkaa same problem here, any solution ?

@ingo-lorenz
Copy link

Is there already a solution for this problem? You cannot use generated PPTX files with charts in current Office versions.

I have already tested the dev-master.

Thanks to you

Ingo

@akmalirfan
Copy link

akmalirfan commented Nov 10, 2020

For my case, I fixed this issue (partially, at least) by changing the source code in 0.9.0 release following the latest source code (at the time of writing) in develop branch. This means, the developers are already working on it but it is not ready for release yet.

Particularly, I changed the code for writing c:hPercent in PptCharts.php by deleting the percent symbol and the code for writing a:alpha in AbstractDecoratorWriter.php by deleting the percent symbol and multiply the $alpha by 1000.

These files can be found in /src/PhpPresentation/Writer/PowerPoint2007/

Now, when I exported the .pptx, the chart can be viewed when I opened it using PowerPoint Online. It might still does not pass the validation but at least, the chart is visible now. That is what important to me.

Lastly, thank you to the developers and all contributors for this library.

EDIT: Or you can just simply use the develop branch by specifying "dev-develop" in your composer.json. And also, for the file generated using develop branch, I found no validation error when validating it using Open XML SDK 2.5.

@Progi1984
Copy link
Member

Hi all, I think it is fixed on develop branch. Could you check it @akmalirfan @ingo-lorenz @MehdiAroui @AlexanderKulia ?

@akmalirfan
Copy link

Yes it is. Thanks @Progi1984

@Progi1984 Progi1984 unpinned this issue Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests