You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用App Script统一设置Google文档项目符号列表的字形样式

批量修复Google文档项目符号样式的App Script方案
  • 核心逻辑:通过App Script遍历文档所有段落,识别列表项后统一设置项目符号样式,无需手动逐个调整。

  • 代码实现:

    function batchSetBulletStyles() {
      const targetDoc = DocumentApp.getActiveDocument();
      const docBody = targetDoc.getBody();
      const allParagraphs = docBody.getParagraphs();
      
      allParagraphs.forEach(paragraph => {
        // 识别带列表结构的段落
        if (paragraph.getListId()) {
          const listStyle = paragraph.getListStyle();
          // 设置为圆点项目符号,可替换为其他类型
          listStyle.setListType(DocumentApp.ListType.BULLET);
          // 配置缩进参数(72点=1英寸,可按需修改)
          listStyle.setIndentStart(72);
          listStyle.setIndentFirstLine(0);
          paragraph.setListStyle(listStyle);
        }
      });
    }
    
  • 操作步骤:

    1. 打开目标Google文档,点击「扩展程序」→「Apps Script」进入脚本编辑器
    2. 替换默认代码为上述脚本
    3. 点击运行按钮,完成权限授权后等待执行
    4. 执行完毕后,文档内所有列表项会自动应用设置的项目符号样式
  • 自定义选项:

    • 更换符号类型:将DocumentApp.ListType.BULLET替换为DocumentApp.ListType.SQUARE_BULLET(方形)或DocumentApp.ListType.DIAMOND_BULLET(菱形)
    • 调整缩进:修改setIndentStart的数值来改变列表整体缩进量

内容的提问来源于stack exchange,提问作者Mr. T

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 20:00:47