Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
ExcelScript.ConditionalDataBarNegativeFormat interface
- Package:
- ExcelScript
Represents a conditional format for the negative side of the data bar.
Remarks
Used by
Examples
/**
* 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");
}
Methods
| getBorderColor() | HTML color code representing the color of the border line, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange"). Value is "" (an empty string) if no border is present or set. |
| getFillColor() | HTML color code representing the fill color, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange"). |
| getMatchPositiveBorderColor() | Specifies if the negative data bar has the same border color as the positive data bar. |
| getMatchPositiveFillColor() | Specifies if the negative data bar has the same fill color as the positive data bar. |
| setBorderColor(borderColor) | HTML color code representing the color of the border line, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange"). Value is "" (an empty string) if no border is present or set. |
| setFillColor(fillColor) | HTML color code representing the fill color, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange"). |
| setMatchPositiveBorderColor(matchPositiveBorderColor) | Specifies if the negative data bar has the same border color as the positive data bar. |
| setMatchPositiveFillColor(matchPositiveFillColor) | Specifies if the negative data bar has the same fill color as the positive data bar. |
Method Details
getBorderColor()
HTML color code representing the color of the border line, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange"). Value is "" (an empty string) if no border is present or set.
getBorderColor(): string;
Returns
string
getFillColor()
HTML color code representing the fill color, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange").
getFillColor(): string;
Returns
string
getMatchPositiveBorderColor()
Specifies if the negative data bar has the same border color as the positive data bar.
getMatchPositiveBorderColor(): boolean;
Returns
boolean
getMatchPositiveFillColor()
Specifies if the negative data bar has the same fill color as the positive data bar.
getMatchPositiveFillColor(): boolean;
Returns
boolean
setBorderColor(borderColor)
HTML color code representing the color of the border line, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange"). Value is "" (an empty string) if no border is present or set.
setBorderColor(borderColor: string): void;
Parameters
- borderColor
-
string
Returns
void
setFillColor(fillColor)
HTML color code representing the fill color, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange").
setFillColor(fillColor: string): void;
Parameters
- fillColor
-
string
Returns
void
setMatchPositiveBorderColor(matchPositiveBorderColor)
Specifies if the negative data bar has the same border color as the positive data bar.
setMatchPositiveBorderColor(matchPositiveBorderColor: boolean): void;
Parameters
- matchPositiveBorderColor
-
boolean
Returns
void
setMatchPositiveFillColor(matchPositiveFillColor)
Specifies if the negative data bar has the same fill color as the positive data bar.
setMatchPositiveFillColor(matchPositiveFillColor: boolean): void;
Parameters
- matchPositiveFillColor
-
boolean
Returns
void
Office Scripts
Feedback
Was this page helpful?
