ExcelScript.ConditionalDataBarNegativeFormat 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”) 。

getMatchPositiveBorderColor()

指定负数据条是否与正数据条具有相同的边框颜色。

getMatchPositiveFillColor()

指定负数据条是否与正数据条具有相同的填充颜色。

setBorderColor(borderColor)

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

setFillColor(fillColor)

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

setMatchPositiveBorderColor(matchPositiveBorderColor)

指定负数据条是否与正数据条具有相同的边框颜色。

setMatchPositiveFillColor(matchPositiveFillColor)

指定负数据条是否与正数据条具有相同的填充颜色。

方法详细信息

getBorderColor()

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

getBorderColor(): string;

返回

string

getFillColor()

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

getFillColor(): string;

返回

string

getMatchPositiveBorderColor()

指定负数据条是否与正数据条具有相同的边框颜色。

getMatchPositiveBorderColor(): boolean;

返回

boolean

getMatchPositiveFillColor()

指定负数据条是否与正数据条具有相同的填充颜色。

getMatchPositiveFillColor(): 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

setMatchPositiveBorderColor(matchPositiveBorderColor)

指定负数据条是否与正数据条具有相同的边框颜色。

setMatchPositiveBorderColor(matchPositiveBorderColor: boolean): void;

参数

matchPositiveBorderColor

boolean

返回

void

setMatchPositiveFillColor(matchPositiveFillColor)

指定负数据条是否与正数据条具有相同的填充颜色。

setMatchPositiveFillColor(matchPositiveFillColor: boolean): void;

参数

matchPositiveFillColor

boolean

返回

void