witan-pptx-officejs
This page is generated from the witan-pptx-officejs skill source.
npx skills add witanlabs/witan-cli \
--skill witan-pptx-officejs
Running in Claude Cowork? The
witanCLI isn't preinstalled — see references/cowork-setup.md for install steps.
Quick Reference
Render a slide:
witan pptx render deck.pptx --slide 1 -o slide-1.png
Run Office.js-compatible JavaScript:
witan pptx exec deck.pptx --stdin <<'JS'
return await PowerPoint.run(async context => {
const count = context.presentation.slides.getCount();
await context.sync();
return count.value;
});
JS
Save changes:
witan pptx exec deck.pptx --save --stdin <<'JS'
return await PowerPoint.run(async context => {
const slide = context.presentation.slides.getItemAt(0);
slide.shapes.addTextBox("Updated", { left: 60, top: 60, width: 300, height: 80 });
await context.sync();
return true;
});
JS
Create a new deck:
witan pptx exec new.pptx --create --save --stdin <<'JS'
return await PowerPoint.run(async context => {
const slides = context.presentation.slides;
slides.add();
const count = slides.getCount();
await context.sync();
const slide = slides.getItemAt(count.value - 1);
slide.shapes.addTextBox("Created", { left: 60, top: 60, width: 300, height: 80 });
await context.sync();
return count.value;
});
JS
Create and style a chart:
witan pptx exec charts.pptx --create --save --stdin <<'JS'
return await PowerPoint.run(async context => {
const slide = context.presentation.slides.getItemAt(0);
const shape = slide.shapes.addChart(PowerPoint.ChartType.columnClustered, [
["Quarter", "Revenue", "Margin"],
["Q1", 12, 0.31],
["Q2", 18, 0.34],
["Q3", 25, 0.39]
], { left: 48, top: 72, width: 420, height: 240, name: "Revenue Chart", seriesBy: "columns" });
const chart = shape.getChart();
chart.title.text = "Revenue and Margin";
chart.legend.position = "Top";
chart.axes.valueAxis.title.text = "Revenue";
chart.series.getItemAt(1).chartType = PowerPoint.ChartType.lineMarkers;
chart.series.getItemAt(1).axisGroup = PowerPoint.ChartAxisGroup.secondary;
await context.sync();
return chart.name;
});
JS
Guidance
- Use
--stdinwith a quoted heredoc for multi-line scripts. - Use
--saveonly when changes should be written back. - Use
--createwith a new.pptxpath to run against an empty PPTX file; add--saveto write the created file locally. - Use
--jsonwhen automation needs the full response envelope. - Use
--input-jsonto pass structured data as theinputglobal. - Use
witan pptx render deck.pptx --slide 1 --diff baseline.pngfor visual regression checks. - After chart authoring or mutation, render the affected slide with
witan pptx renderto verify visual output.
Top-level await is supported. Static and dynamic imports are not available.
Chart Extensions
Witan PPTX includes an Excel-style chart API adapted to PPTX. This is a Witan extension: upstream Office.js PowerPoint declarations do not include these chart APIs.
- Create charts with
slide.shapes.addChart(PowerPoint.ChartType.columnClustered, values, options). - Access charts with
shape.getChart()orshape.getChartOrNullObject(). - Mutate chart titles, legends, axes, series, data labels, fills, borders, and fonts with property-style accessors such as
chart.title.text,chart.axes.valueAxis.maximum, andchart.series.getItemAt(0).name. - Replace chart data with
chart.setData(values, options)or repoint embedded workbook ranges withchart.setDataRange("Sheet1!A1:B4", { seriesBy: "columns" }). - Delete charts with
chart.delete()or delete the containing shape withshape.delete(). - The
exec-typesdeclarations (see References) are the authoritative reference for Witan-only chart members and enum values.
References
The authoritative TypeScript declarations for the exec sandbox are served by the CLI (not bundled with this skill), combining the Office.js PowerPoint surface and the Witan chart extensions in a single .d.ts. Fetch them only when you need to, for example:
- Confirming a Witan chart-extension member or enum value (see Chart Extensions) that isn't part of standard Office.js.
- Resolving an unexpected runtime error or an API signature you're genuinely unsure about.
When you do fetch, pull them once per session and search the local copy (e.g grep) — the file is ~2 MB, so never read it wholesale.
witan pptx exec-types > "${TMPDIR:-/tmp}/witan-pptx-types.d.ts"
PowerPoint.createPresentation(...)is intentionally not implemented; usewitan pptx exec <file> --create --saveto create a PPTX file through the CLI.
Witan PPTX follows the Office.js PowerPoint API surface where implemented and extends it with chart APIs. OfficeExtension.ClientResult values must be read after await context.sync(), and APIs returning void should not be treated as object factories.