C# .NET客户端中Google工作表中的条件格式请求
我知道如何在GoogleSheetsAPI中对值和其他格式进行批处理电子表格更新请求,但条件格式似乎有所不同。我已正确设置请求:C# .NET客户端中Google工作表中的条件格式请求,c#,google-sheets-api,google-api-dotnet-client,gs-conditional-formatting,C#,Google Sheets Api,Google Api Dotnet Client,Gs Conditional Formatting,我知道如何在GoogleSheetsAPI中对值和其他格式进行批处理电子表格更新请求,但条件格式似乎有所不同。我已正确设置请求: AddConditionalFormatRuleRequest formatRequest = new AddConditionalFormatRuleRequest { Rule = new ConditionalFormatRule { Ranges = new List<GridRange> {
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.Requests
的类型为IList
,但AddConditionalFormatureRequest
不会从请求继承。它只实现了IDirectResponseActionSchema
(参见第2254行),那么实际如何执行这些请求呢
因此,我应该使用其他的对象/方法来实现这一点,但它在哪里
提前感谢。来自.NET背景,我真的很难理解如何使用Google API。(对我来说)事情组织得很奇怪,.NET组件的文档看起来一点也不像MSDN,所以我觉得很难。不管怎样,我知道了。您不能单独使用addConditionalFormatureRequest
类。您必须将其包装在常规的请求
对象中
Request formatRequest = new Request
{
AddConditionalFormatRule = new AddConditionalFormatRuleRequest
{
// etc
}
};
Request formatRequest = new Request
{
AddConditionalFormatRule = new AddConditionalFormatRuleRequest
{
// etc
}
};