PPTX

SmartArt

创建预定义的 SmartArt 图示,用于流程、层级结构等

使用 SmartArtFrame 添加 SmartArt 图形 — 预定义的图示布局,用于可视化流程、层级结构、关系等。

基本 SmartArt

import { Slide, SmartArtFrame } from "@office-open/pptx";

new Slide({
    children: [
        new SmartArtFrame({
            x: 1,
            y: 1,
            width: 8,
            height: 4,
            layout: "process",
            data: [
                { text: "Step 1", bullets: ["Detail A"] },
                { text: "Step 2", bullets: ["Detail B"] },
                { text: "Step 3", bullets: ["Detail C"] },
            ],
        }),
    ],
});

可用布局

常用的 SmartArt 布局包括:

布局说明
process顺序流程步骤
cycle循环/重复流程
hierarchy组织层级结构
relationship径向/关系图
matrix矩阵布局
pyramid金字塔/比例关系
list垂直列表
chevron箭头流程

层级结构示例

new SmartArtFrame({
    x: 0.5,
    y: 0.5,
    width: 9,
    height: 5,
    layout: "hierarchy",
    data: [
        { text: "CEO" },
        {
            text: "CTO",
            bullets: ["Engineering", "Product"],
        },
        {
            text: "CFO",
            bullets: ["Finance", "Accounting"],
        },
    ],
});

循环示例

new SmartArtFrame({
    x: 1,
    y: 1,
    width: 7,
    height: 4,
    layout: "cycle",
    data: [
        { text: "Plan" },
        { text: "Design" },
        { text: "Develop" },
        { text: "Test" },
        { text: "Deploy" },
    ],
});

SmartArt 样式

控制配色方案和快速样式:

new SmartArtFrame({
    x: 1,
    y: 1,
    width: 8,
    height: 4,
    layout: "process",
    data: [{ text: "Phase 1" }, { text: "Phase 2" }, { text: "Phase 3" }],
    colorStyle: "accent2_1", // 配色方案
    quickStyle: "simple", // 视觉样式
});

带项目符号的嵌套数据

new SmartArtFrame({
    x: 1,
    y: 1,
    width: 8,
    height: 5,
    layout: "list",
    data: [
        {
            text: "Strategy",
            bullets: ["Market Analysis", "Competitive Review", "Growth Planning"],
        },
        {
            text: "Execution",
            bullets: ["Product Development", "Sales & Marketing"],
        },
    ],
});

配色方案

可用的配色方案选项:

说明
"accent1_1""accent6_1"强调色,变体 1
"accent1_2""accent6_2"强调色,变体 2
"accent1_3""accent6_3"强调色,变体 3
"colorful"多色
"primary"主主题色

快速样式

说明
"simple"简洁外观
"whiteOutline"白色轮廓样式
"intense"醒目高对比
"gradient"渐变填充
"flat"扁平,无 3D 效果

SmartArtFrame 选项

选项类型说明
xnumber水平位置(英寸)
ynumber垂直位置(英寸)
widthnumber宽度(英寸)
heightnumber高度(英寸)
layoutstringSmartArt 布局名称
dataarray{ text, bullets? } 对象数组
colorStylestring配色方案标识符
quickStylestring视觉样式标识符
Copyright © 2026