pptxgenjs导出PPT

2023-04-18  本文已影响0人  coderfl

npm install pptxgenjs --save
yarn add pptxgenjs

<template>
  <el-button @click="exportPPT">导出</el-button>
</template>

<script>
import PptxGenJS from "pptxgenjs";

export default {
  name: "ppt",
  methods: {
    exportPPT() {
      // 1. Create a Presentation
      let pres = new PptxGenJS();

      // 2. Add a Slide to the presentation
      let slide = pres.addSlide();

      // 3. Add 1+ objects (Tables, Shapes, etc.) to the Slide
      slide.addText("Hello World from PptxGenJS...", {
        x: 1.5,
        y: 1.5,
        color: "363636",
        fill: { color: "F1F1F1" },
        align: pres.AlignH.center,
      });

      // 4. Save the Presentation
      pres.writeFile({ fileName: "Sample Presentation.pptx" });
    }
  },
}
</script>

官方文档:https://gitbrent.github.io/PptxGenJS/

上一篇 下一篇

猜你喜欢

热点阅读