【问题标题】:Google Docs API create an empty documentGoogle Docs API 创建一个空文档
【发布时间】:2020-10-05 10:59:35
【问题描述】:

我现在尝试使用 Ggoogle Docs API 和我的内容创建一个文档,但是每次我创建它都会出现空洞,我应该如何解决这个问题?

我使用来自 google 示例的相同代码来执行此操作。 link to example

我的内容示例:

      {
        "title": "testitesti",
        "body": {
          "content": [
            {
              "endIndex": 1,
              "sectionBreak": {
                "sectionStyle": {
                  "columnSeparatorStyle": "NONE",
                  "contentDirection": "LEFT_TO_RIGHT",
                  "sectionType": "CONTINUOUS"
                }
              }
            },
            {
              "startIndex": 1,
              "endIndex": 6,
              "paragraph": {
                "elements": [
                  {
                    "startIndex": 1,
                    "endIndex": 6,
                    "textRun": {
                      "content": "test\n",
                      "textStyle": {}
                    }
                  }
                ],
                "paragraphStyle": {
                  "namedStyleType": "NORMAL_TEXT",
                  "direction": "LEFT_TO_RIGHT"
                }
              }
            }
          ]
        }
      }

谢谢

【问题讨论】:

    标签: javascript python-3.x google-docs google-docs-api google-developers-console


    【解决方案1】:

    documents.create 将始终创建空白文档:

    使用请求中给出的标题创建一个空白文档。 请求中的其他字段,包括任何提供的内容,都会被忽略

    如果您想使用document resource 属性向文档添加内容,请使用documents.batchUpdate

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-07
      • 1970-01-01
      • 2012-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多