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

addCustomProperty(key, value)

Creates a new or sets an existing custom property.

deleteAllCustomProperties()

Deletes all custom properties in this collection.

getAuthor()

The author of the workbook.

getCategory()

The category of the workbook.

getComments()

The comments of the workbook.

getCompany()

The company of the workbook.

getCreationDate()

Gets the creation date of the workbook.

getCustom()

Gets the collection of custom properties of the workbook.

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.

getKeywords()

The keywords of the workbook.

getLastAuthor()

Gets the last author of the workbook.

getManager()

The manager of the workbook.

getRevisionNumber()

Gets the revision number of the workbook.

getSubject()

The subject of the workbook.

getTitle()

The title of the workbook.

setAuthor(author)

The author of the workbook.

setCategory(category)

The category of the workbook.

setComments(comments)

The comments of the workbook.

setCompany(company)

The company of the workbook.

setKeywords(keywords)

The keywords of the workbook.

setManager(manager)

The manager of the workbook.

setRevisionNumber(revisionNumber)

Gets the revision number of the workbook.

setSubject(subject)

The subject of the workbook.

setTitle(title)

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 comments of 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

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 comments of 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