1

我想将 column 更新为 columnB值为的1行。在 SQL 术语中,一个简单的A2

UPDATE SpreadSheet 
SET B = 1
WHERE A = 2 

这可以通过对 Google Docs 的一两次调用来完成,而不必遍历行/列吗?

4

1 回答 1

2

我无法使用BA找不到不循环进行更新的方法。此示例使用列标题(第一行的值)。用您自己的列替换id和。val

WorksheetFeed wsFeed = spreadsheet.Worksheets;
WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];

// Define the URL to request the list feed of the worksheet.
AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

// Fetch the list feed of the worksheet.
ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
listQuery.SpreadsheetQuery = "id = 2";
ListFeed listFeed = service.Query(listQuery);

var row = (ListEntry)listFeed.Entries[0];

foreach (ListEntry.Custom element in row.Elements)
{
    if (element.LocalName == "val")
    {
        element.Value = "1";
    }
}
row.Update();
于 2013-01-20T19:49:19.927 回答