ExcelScript.DocumentPropertyType enum
Remarks
Examples
/**
* This script uses a custom property to set the value and formatting of a cell.
* If the value of "Routing Number" is not set or is not a number, the cell will be red.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first cell from Sheet1.
const cell = workbook.getWorksheet("Sheet1").getCell(0,0);
// Get the "Routing Number" property.
const properties = workbook.getProperties();
const routingNumber = properties.getCustomProperty("Routing Number");
// If the property is missing or is not a number, change the formatting to indicate a problem.
if (!routingNumber || routingNumber.getType() != ExcelScript.DocumentPropertyType.number) {
cell.getFormat().getFill().setColor("red");
}
// If the property exists, use it to set the value of A1.
if (routingNumber) {
cell.setValue(routingNumber.getValue());
}
}
Fields
boolean | |
date | |
float | |
number | |
string |
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Office Scripts