RangeFill Object (JavaScript API for Excel)
Represents the background of a range object.
Properties
Property | Type | Description | Req. Set |
---|---|---|---|
color | string | HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange") | 1.1 |
See property access examples.
Relationships
None
Methods
Method | Return Type | Description | Req. Set |
---|---|---|---|
clear() | void | Resets the range background. | 1.1 |
Method Details
clear()
Resets the range background.
Syntax
rangeFillObject.clear();
Parameters
None
Returns
void
Examples
This example resets the range background.
Excel.run(function (ctx) {
var sheetName = "Sheet1";
var rangeAddress = "F:G";
var worksheet = ctx.workbook.worksheets.getItem(sheetName);
var range = worksheet.getRange(rangeAddress);
var rangeFill = range.format.fill;
rangeFill.clear();
return ctx.sync();
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
Property access examples
Excel.run(function (ctx) {
var sheetName = "Sheet1";
var rangeAddress = "F:G";
var worksheet = ctx.workbook.worksheets.getItem(sheetName);
var range = worksheet.getRange(rangeAddress);
var rangeFill = range.format.fill;
rangeFill.load('color');
return ctx.sync().then(function() {
console.log(rangeFill.color);
});
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
The example below sets fill color.
Excel.run(function (ctx) {
var sheetName = "Sheet1";
var rangeAddress = "F:G";
var range = ctx.workbook.worksheets.getItem(sheetName).getRange(rangeAddress);
range.format.fill.color = '0000FF';
return ctx.sync();
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});