ExcelScript.DocumentProperties interface
Represents workbook properties.
Remarks
Examples
/**
* This script creates a new worksheet that displays some of the document properties.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the document properties.
const properties: ExcelScript.DocumentProperties = workbook.getProperties();
// Create a new worksheet called "Metadata".
const newWorksheet = workbook.addWorksheet("Metadata");
// Create an array to store the string values of properties to save.
let values: string[][] = [];
values.push(["Creation Date", properties.getCreationDate().toString()]);
values.push(["Author", properties.getAuthor()]);
values.push(["Last Edited By", properties.getLastAuthor()]);
// Set the property values to a range on the new worksheet.
newWorksheet.getRange("A1:B3").setValues(values);
}
Methods
add |
Creates a new or sets an existing custom property. |
delete |
Deletes all custom properties in this collection. |
get |
The author of the workbook. |
get |
The category of the workbook. |
get |
The comment field in the metadata of the workbook. These have no connection to comments by users made in the workbook. |
get |
The company of the workbook. |
get |
Gets the creation date of the workbook. |
get |
Gets the collection of custom properties of the workbook. |
get |
Gets a custom property object by its key, which is case-insensitive. If the custom property doesn't exist, then this method returns |
get |
The keywords of the workbook. |
get |
Gets the last author of the workbook. |
get |
The manager of the workbook. |
get |
Gets the revision number of the workbook. |
get |
The subject of the workbook. |
get |
The title of the workbook. |
set |
The author of the workbook. |
set |
The category of the workbook. |
set |
The comment field in the metadata of the workbook. These have no connection to comments by users made in the workbook. |
set |
The company of the workbook. |
set |
The keywords of the workbook. |
set |
The manager of the workbook. |
set |
Gets the revision number of the workbook. |
set |
The subject of the workbook. |
set |
The title of the workbook. |
Method Details
addCustomProperty(key, value)
Creates a new or sets an existing custom property.
addCustomProperty(key: string, value: any): CustomProperty;
Parameters
- key
-
string
Required. The custom property's key, which is case-insensitive. The key is limited to 255 characters outside of Excel on the web (larger keys are automatically trimmed to 255 characters on other platforms).
- value
-
any
Required. The custom property's value. The value is limited to 255 characters outside of Excel on the web (larger values are automatically trimmed to 255 characters on other platforms).
Returns
Examples
/**
* This script adds a workbook-level custom property.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the property collection.
const properties = workbook.getProperties();
// Add a new property called "Project" with the value "FA".
properties.addCustomProperty("Project", "FA");
}
deleteAllCustomProperties()
Deletes all custom properties in this collection.
deleteAllCustomProperties(): void;
Returns
void
getAuthor()
The author of the workbook.
getAuthor(): string;
Returns
string
getCategory()
The category of the workbook.
getCategory(): string;
Returns
string
getComments()
The comment field in the metadata of the workbook. These have no connection to comments by users made in the workbook.
getComments(): string;
Returns
string
getCompany()
The company of the workbook.
getCompany(): string;
Returns
string
getCreationDate()
Gets the creation date of the workbook.
getCreationDate(): Date;
Returns
Date
getCustom()
Gets the collection of custom properties of the workbook.
getCustom(): CustomProperty[];
Returns
getCustomProperty(key)
Gets a custom property object by its key, which is case-insensitive. If the custom property doesn't exist, then this method returns undefined
.
getCustomProperty(key: string): CustomProperty | undefined;
Parameters
- key
-
string
Required. The key that identifies the custom property object.
Returns
ExcelScript.CustomProperty | undefined
Examples
/**
* This script gets a workbook-level custom property called "Project".
*/
function main(workbook: ExcelScript.Workbook) {
// Get the property collection.
const properties = workbook.getProperties();
// Get the "Project" property.
const project = properties.getCustomProperty("Project");
// Show the property value in the console.
console.log(project.getValue());
}
getKeywords()
The keywords of the workbook.
getKeywords(): string;
Returns
string
getLastAuthor()
Gets the last author of the workbook.
getLastAuthor(): string;
Returns
string
getManager()
The manager of the workbook.
getManager(): string;
Returns
string
getRevisionNumber()
Gets the revision number of the workbook.
getRevisionNumber(): number;
Returns
number
getSubject()
The subject of the workbook.
getSubject(): string;
Returns
string
getTitle()
The title of the workbook.
getTitle(): string;
Returns
string
setAuthor(author)
The author of the workbook.
setAuthor(author: string): void;
Parameters
- author
-
string
Returns
void
setCategory(category)
The category of the workbook.
setCategory(category: string): void;
Parameters
- category
-
string
Returns
void
setComments(comments)
The comment field in the metadata of the workbook. These have no connection to comments by users made in the workbook.
setComments(comments: string): void;
Parameters
- comments
-
string
Returns
void
setCompany(company)
The company of the workbook.
setCompany(company: string): void;
Parameters
- company
-
string
Returns
void
setKeywords(keywords)
The keywords of the workbook.
setKeywords(keywords: string): void;
Parameters
- keywords
-
string
Returns
void
setManager(manager)
The manager of the workbook.
setManager(manager: string): void;
Parameters
- manager
-
string
Returns
void
setRevisionNumber(revisionNumber)
Gets the revision number of the workbook.
setRevisionNumber(revisionNumber: number): void;
Parameters
- revisionNumber
-
number
Returns
void
setSubject(subject)
The subject of the workbook.
setSubject(subject: string): void;
Parameters
- subject
-
string
Returns
void
setTitle(title)
The title of the workbook.
setTitle(title: string): void;
Parameters
- title
-
string
Returns
void
Office Scripts