0

I am working with an export function by using PptxGenJS. It does not work even with basic example code from demo source code on official Github. I am working with export charts.

My steps:

  • Install PptxGenJS and import like normal npm package.
  • Copy code from official demo: slide.addChart( pptx.charts.BAR, arrDataRegions, optsChartBar1 );

The result:

  • Chart show nothing in exported slider.
  • Open with Microsoft Powerpoint 2013, it shows some error similar to this question.
  • My codesanbox even worse, no file were downloaded.

My notable package versions:

"react": "^16.13.1",
"pptxgenjs": "^2.6.0",

My environment versions:

  • node version: v10.17.0
  • npm version: v6.11.3
  • Windows 10 Pro 1903, OS build 18362.1082

Both two versions of Pptxgenjs do not work. Any thoughts on this? Thanks for any idea. I'm giving up on this library.

ShinaBR2
  • 2,519
  • 2
  • 14
  • 26

1 Answers1

0

Maybe case-sensitive. Change your BAR to bar like below,

import pptxgen from "pptxgenjs";

let pres = new pptxgen();
let slide = pres.addSlide();
let dataChartAreaLine = [
            {
                name: "Actual Sales",
                labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
                values: [1500, 4600, 5156, 3167, 8510, 8009],
            },
            {
                name: "Projected Sales",
                labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
                values: [1000, 2600, 3456, 4567, 5010, 6009],
            },
        ];

        slide.addChart(pres.ChartType.bar, dataChartAreaLine, { x: 2, y: 2, w: 6, h: 3, showLegend: true });

pres.writeFile("Sample Presentation.pptx");
David Buck
  • 3,752
  • 35
  • 31
  • 35
Boopathy
  • 46
  • 1
  • 1
  • 7
  • Thanks for your answer. The thing is now I am not continued that project anymore :)) don't have time to confirm again. – ShinaBR2 Nov 13 '20 at 15:51