。NET客户端中Google表格中的标准格式请求

问题描述 投票:1回答:1

我知道如何对Google Sheets API中的值和其他格式进行批量电子表格更新请求,但条件格式似乎有所不同。我的请求设置正确:

AddConditionalFormatRuleRequest formatRequest = new AddConditionalFormatRuleRequest
{
    Rule = new ConditionalFormatRule
    {
        Ranges = new List<GridRange>
        {
            new GridRange
            {
                // omitted
            }
        },
        BooleanRule = new BooleanRule
        {
            Condition = new BooleanCondition
            {
                // omitted
            },
            Format = new CellFormat
            {
                // omitted
            }
        },
    },
};
formatRequests.Add(formatRequest);

问题是,您实际上如何执行此操作?问题出在这里:

BatchUpdateSpreadSheetRequest updateRequest = new BatchUpdateSpreadsheetRequest 
{ 
    Requests = formatRequests  // this doesn't work
};
// resource is a SpreadsheetsResource object
SpreadsheetsResource.BatchUpdateRequest batchRequest = resource.BatchUpdate(updateRequest, spreadsheet.SpreadsheetId);

此部分不起作用,因为BatchUpdateSpreadSheetRequest.Requests的类型为IList<Request>,但AddConditionalFormatRuleRequest不继承自Request。它仅实现IDirectResponseActionSchema(请参见source code第2254行),因此一个人实际上是如何执行这些请求的??

因此必须有其他一些对象/方法可以用来执行此操作,但是它在哪里?

提前感谢。

我知道如何对Google Sheets API中的值和其他格式进行批量电子表格更新请求,但条件格式似乎有所不同。我的请求设置正确:...

c# google-sheets-api google-api-dotnet-client gs-conditional-formatting
1个回答
0
投票

来自.NET背景,我真的很难理解如何使用Google API。 (对我而言)事情组织得很奇怪,.NET组件的文档看起来与MSDN完全不同,所以我觉得很困难。无论如何,我想通了。您不能单独使用AddConditionalFormatRuleRequest类。您必须将其包装在常规Request对象中。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.