ExcelScript.ConditionalDataBarPositiveFormat interface

表示数据条正端的条件格式。

注解

示例

/**
 * This script applies data bar conditional formatting to a range.
 * It sets the data bar colors to be green when positive and red when negative.
 */
function main(workbook: ExcelScript.Workbook) {
    // Get the "Sales" data column range in a table named "SalesTable".
    const table = workbook.getTable("SalesTable");
    const salesRange = table.getColumnByName("Sales").getRangeBetweenHeaderAndTotal();

    // Add data bar conditional formatting to the range.
    const cf = salesRange.addConditionalFormat(ExcelScript.ConditionalFormatType.dataBar);

    // Have the bar show green when positive and red when negative. 
    const dataBarConditionalFormat = cf.getDataBar();
    const positiveFormat: ExcelScript.ConditionalDataBarPositiveFormat = dataBarConditionalFormat.getPositiveFormat();
    positiveFormat .setFillColor("green");
    const negativeFormat: ExcelScript.ConditionalDataBarNegativeFormat = dataBarConditionalFormat.getNegativeFormat();
    negativeFormat.setFillColor("red");
}

方法

getBorderColor()

表示边框线颜色的 HTML 颜色代码,格式 #RRGGBB (例如“FFA500”) 或命名的 HTML 颜色 (例如“橙色”) 。 如果不存在或未设置边框,则值为“” (空字符串) 。

getFillColor()

表示填充颜色的 HTML 颜色代码,格式 #RRGGBB (例如“FFA500”) 或命名的 HTML 颜色 (例如“orange”) 。

getGradientFill()

指定数据条是否具有渐变。

setBorderColor(borderColor)

表示边框线颜色的 HTML 颜色代码,格式 #RRGGBB (例如“FFA500”) 或命名的 HTML 颜色 (例如“橙色”) 。 如果不存在或未设置边框,则值为“” (空字符串) 。

setFillColor(fillColor)

表示填充颜色的 HTML 颜色代码,格式 #RRGGBB (例如“FFA500”) 或命名的 HTML 颜色 (例如“orange”) 。

setGradientFill(gradientFill)

指定数据条是否具有渐变。

方法详细信息

getBorderColor()

表示边框线颜色的 HTML 颜色代码,格式 #RRGGBB (例如“FFA500”) 或命名的 HTML 颜色 (例如“橙色”) 。 如果不存在或未设置边框,则值为“” (空字符串) 。

getBorderColor(): string;

返回

string

getFillColor()

表示填充颜色的 HTML 颜色代码,格式 #RRGGBB (例如“FFA500”) 或命名的 HTML 颜色 (例如“orange”) 。

getFillColor(): string;

返回

string

getGradientFill()

指定数据条是否具有渐变。

getGradientFill(): boolean;

返回

boolean

setBorderColor(borderColor)

表示边框线颜色的 HTML 颜色代码,格式 #RRGGBB (例如“FFA500”) 或命名的 HTML 颜色 (例如“橙色”) 。 如果不存在或未设置边框,则值为“” (空字符串) 。

setBorderColor(borderColor: string): void;

参数

borderColor

string

返回

void

setFillColor(fillColor)

表示填充颜色的 HTML 颜色代码,格式 #RRGGBB (例如“FFA500”) 或命名的 HTML 颜色 (例如“orange”) 。

setFillColor(fillColor: string): void;

参数

fillColor

string

返回

void

setGradientFill(gradientFill)

指定数据条是否具有渐变。

setGradientFill(gradientFill: boolean): void;

参数

gradientFill

boolean

返回

void