bool SetTabFormatCondition(string mon, TabFormatCondition tArg)
mon. Moniker of the range for working with its conditional formats.
tArg. Updated conditional format settings.
The SetTabFormatCondition operation changes conditional format settings for cell range.
To execute the operation, in the mon field specify regular report instance moniker with the !Sheets!sheet key!range address!FormatConditions!conditional format index postfix, and in the tArg field specify conditional format parameters to be applied.
The operation results in the logical True if the settings were changed successfully.
Below is the example of changing conditional format settings. The request contains conditional format moniker, new conditional format settings, and cell formatting style. The response contains whether change is executed successfully.
{
"SetTabFormatCondition" :
{
"mon" : "S1!M!S!P1!Sheets!1!A0:B3!FormatConditions!0",
"tArg" :
{
"k" : "0",
"Key" : "0",
"Type" : "CellContent",
"Details" :
{
"CellContent" :
{
"ContentType" : "0",
"CellValue" : "100",
"SpecificText" : "",
"Style" :
{
"Font" :
{
"@B" : "true",
"@S" : "10"
}
},
"ValueCondition" : "4",
"TextCondition" : "0",
"DateCondition" : "0",
"MinValue" : "",
"MaxValue" : ""
}
}
}
}
}
{
"SetTabFormatConditionResult" : "1"
}
public static bool SetFormatCondition(string moniker, string sheetKey, string address, string formatKey, string cellValue, TabStyle formatStyle)
{
var somClient = new SomPortTypeClient(); // Proxy object for operation execution
// Operation execution parameters
var tTab = new SetTabFormatCondition()
{
mon = moniker + "!Sheets!" + sheetKey + '!' + address + "!FormatConditions!" + formatKey,
tArg = new TabFormatCondition()
{
Type = TabConditionType.CellContent,
Details = new TabFormatConditionDetails()
{
CellContent = new TabFormatCellContent()
{
ContentType = 0, //TabFormatContentType.CellValue
ValueCondition = 4, //TabConditionCellContentValue.Above
CellValue = cellValue,
Style = formatStyle,
SpecificText = "",
MinValue = "",
MaxValue = ""
}
}
}
};
// Change conditional format parameters
var result = somClient.SetTabFormatCondition(tTab);
return result;
}
See also: