【问题标题】:Cannot delete row in table by Google Docs API无法通过 Google Docs API 删除表中的行
【发布时间】:2020-04-29 02:54:34
【问题描述】:

我使用 Google 文档尝试使用 DeleteTableRowRequest 删除表中的某些行,但我遇到了指定 TableStartLocation 属性的异常。我的代码如下:

public static void DeleteRequestGDocs(List<Request> requestsList, int? index2Del)
        {
            Request request = new Request();
            Location tableLocation = new Location();
            tableLocation.SegmentId = string.Empty;
            tableLocation.Index = 11;

            TableCellLocation tableCellLocationDel = new TableCellLocation();
            tableCellLocationDel.RowIndex = index2Del;
            tableCellLocationDel.ColumnIndex = 0;
            tableCellLocationDel.TableStartLocation = tableLocation;

            DeleteTableRowRequest delRequest = new DeleteTableRowRequest();
            delRequest.TableCellLocation = tableCellLocationDel;
            request.DeleteTableRow = delRequest;

            requestsList.Add(request);
        }

请帮帮我

更新1:程序执行时删除。我遇到了错误“无效的请求 [0].deleteTableRow:无效的表起始位置。必须指定表的起始索引。”下面是代码

var bodyDelete = new BatchUpdateDocumentRequest();
                    bodyDelete.Requests = requestsDeleteList;
                    var batchDeleteRequest = docsService.Documents.BatchUpdate(bodyDelete, mergedFile.Id);
                    var resultDelete = await batchDeleteRequest.ExecuteAsync();

【问题讨论】:

  • 异常说明了什么?
  • 异常说“Invalid requests[0].deleteTableRow: Invalid table start location.必须指定表的开始索引。”
  • 你好@MouseOnMars,请帮帮我!

标签: c# api documentation delete-row


【解决方案1】:

您应确保请求中的tableStartLocation 与您正在编辑的文档中尝试访问的表的startIndex 的值相匹配。

带有startIndex 的文档 JSON 的对应部分应如下所示:

      {
        "startIndex": 12,
        "endIndex": 23,
        "table": {...}
      },

在此处查看 google tracker 中的相关问题:https://issuetracker.google.com/issues/158124540

【讨论】:

    猜你喜欢
    • 2012-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-02
    • 1970-01-01
    • 2022-01-24
    • 2015-06-07
    • 1970-01-01
    相关资源
    最近更新 更多