Skip to content

Commit a6661c6

Browse files
[excel] Update reference docs with latest IntelliSense file (#403)
* [excel] Update reference docs with latest IntelliSense file * Adjust preview APIs overview article * Move namespace details to permanent location * Apply suggestions from code review Co-authored-by: Alex Jerabek <[email protected]> --------- Co-authored-by: Alex Jerabek <[email protected]>
1 parent 5fa7bd9 commit a6661c6

File tree

3 files changed

+33
-63
lines changed

3 files changed

+33
-63
lines changed

docs/docs-ref-autogen/overview.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Office Scripts API reference
33
description: An overview of the Office Scripts JavaScript APIs.
44
ms.topic: overview
5-
ms.date: 10/01/2022
5+
ms.date: 12/04/2025
66
---
77

88
# Office Scripts API reference
@@ -12,6 +12,10 @@ The Office Scripts API lets you automate common tasks in Excel. Use this referen
1212
> [!NOTE]
1313
> If you're looking for the JavaScript APIs for developing Office Add-ins, visit the [Office Add-ins JavaScript API reference](/javascript/api/overview?view=excel-js-preview&preserve-view=true).
1414
15+
## Namespaces
16+
17+
Office Scripts APIs use two namespaces: [OfficeScript](/javascript/api/office-scripts/officescript) for APIs that are not connected to an Excel workbook, and [ExcelScript](/javascript/api/office-scripts/excelscript) for APIs that work with Excel workbooks.
18+
1519
## Common classes
1620

1721
The following list breaks down the basics of the Office Scripts object model. This shows the common classes and how they relate to one another.

docs/docs-ref-autogen/preview-apis.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Office Scripts preview APIs
33
description: Details about upcoming Office Scripts APIs.
44
ms.topic: whats-new
5-
ms.date: 09/12/2025
5+
ms.date: 12/04/2025
66
---
77

88
# Office Scripts preview APIs
@@ -12,19 +12,12 @@ New Office Scripts APIs are first introduced in "preview", and then later releas
1212
> [!IMPORTANT]
1313
> Preview APIs are subject to change and are not intended for use in a production environment. We recommend that you try them out in test and development environments only. Do not use preview APIs in a production environment or within business-critical documents.
1414
15-
The following table provides a concise summary of the APIs, while the subsequent [API list](#api-list) section gives a detailed list.
16-
17-
| Feature area | Description | Relevant objects |
18-
|:--- |:--- |:--- |
19-
| Save and email a PDF | Save a worksheet as a PDF and email it to yourself or your team. For a sample, see [Save a worksheet and email it as a PDF](/office/dev/scripts/resources/samples/save-as-pdf-email-as-pdf). | [EmailAttachment](/javascript/api/office-scripts/officescript/officescript.emailattachment), [MailProperties](/javascript/api/office-scripts/officescript/officescript.mailproperties) |
20-
2115
## API list
2216

23-
Office Scripts APIs use two namespaces: `OfficeScript` for APIs that are not connected to an Excel workbook, and `ExcelScript` for APIs that work with Excel workbooks. Currently, the only preview APIs are in the `OfficeScript` namespace. The following section lists those APIs.
24-
25-
### OfficeScript namespace
26-
27-
[!INCLUDE[API table](../includes/officescript-preview.md)]
17+
<!-- [!INCLUDE[API table](../includes/officescript-preview.md)] -->
18+
<!-- [!INCLUDE[API table](../includes/excelscript-preview.md)] -->
19+
> [!NOTE]
20+
> There are currently no APIs in preview.
2821
2922
## See also
3023

generate-docs/script-inputs/office-scripts-docs.d.ts

Lines changed: 23 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,7 @@ declare namespace ExcelScript {
18861886
getEntireRow(): Range;
18871887

18881888
/**
1889-
* Returns a range object that includes the current range and up to the edge of the range, based on the provided direction. This matches the <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Arrow key</kbd> behavior in the Excel on Windows UI.
1889+
* Returns a range object that includes the current range and up to the edge of the range, based on the provided direction. This matches the Ctrl+Shift+Arrow key behavior in the Excel on Windows UI.
18901890
* @param direction The direction from the active cell.
18911891
* @param activeCell The active cell in this range. By default, the active cell is the top-left cell of the range. An error is thrown if the active cell is not in this range.
18921892
*/
@@ -1946,7 +1946,7 @@ declare namespace ExcelScript {
19461946
getPrecedents(): WorkbookRangeAreas;
19471947

19481948
/**
1949-
* Returns a range object that is the edge cell of the data region that corresponds to the provided direction. This matches the <kbd>Ctrl</kbd>+<kbd>Arrow key</kbd> behavior in the Excel on Windows UI.
1949+
* Returns a range object that is the edge cell of the data region that corresponds to the provided direction. This matches the Ctrl+Arrow key behavior in the Excel on Windows UI.
19501950
* @param direction The direction from the active cell.
19511951
* @param activeCell The active cell in this range. By default, the active cell is the top-left cell of the range. An error is thrown if the active cell is not in this range.
19521952
*/
@@ -15226,106 +15226,93 @@ declare namespace ExcelScript {
1522615226
declare namespace OfficeScript {
1522715227
/**
1522815228
* Saves a copy of the current workbook in OneDrive, in the same directory as the original file, with the specified file name.
15229-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
15229+
* This API must be called before other APIs.
1523015230
* @param filename The file name of the copied and saved file. The file name must end with ".xlsx".
15231-
* @throws InvalidExtensionError The error thrown if the file name doesn't end with ".xlsx".
15232-
* @throws SaveCopyAsFileMayAlreadyExistError The error thrown if the file name of the copy already exists.
15233-
* @throws SaveCopyAsErrorInvalidCharacters The error thrown if the file name contains invalid characters.
15234-
* @throws SaveCopyAsFileNotOnOneDriveError The error thrown if the document is not saved to OneDrive.
15235-
* @throws ExternalApiTimeout The error thrown if the API reaches the timeout limit of 30 seconds. Note that the copy may still be created.
15231+
* @throws `SaveCopyAsInvalidExtension` Thrown if the file name doesn't end with ".xlsx".
15232+
* @throws `SaveCopyAsMustBeCalledFirst` Thrown if this method is called after other APIs.
15233+
* @throws `SaveCopyAsFileMayAlreadyExist` Thrown if the file name of the copy already exists.
15234+
* @throws `SaveCopyAsInvalidCharacters` Thrown if the file name contains invalid characters.
15235+
* @throws `SaveCopyAsFileNotOnOneDrive` Thrown if the document is not saved to OneDrive.
15236+
* @throws `ExternalApiTimeout` Thrown if the API reaches the timeout limit of 30 seconds. Note that the copy may still be created.
1523615237
*/
1523715238
function saveCopyAs(filename: string): void;
1523815239

1523915240
/**
1524015241
* Converts the document to a PDF and returns the text encoding of it.
15241-
* Note: Recent changes made to the workbook in Excel on the web, through Office Scripts or the Excel UI, may not be captured in the PDF.
15242-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1524315242
* @returns The content of the workbook as a string, in PDF format.
15244-
* @throws ConvertToPdfEmptyWorkbook The error thrown if the document is empty.
15245-
* @throws ConvertToPdfProtectedWorkbook The error thrown if the document is protected.
15246-
* @throws ExternalApiTimeout The error thrown if the API reaches the timeout limit of 30 seconds.
15243+
* @throws `ConvertToPdfEmptyWorkbook` Thrown if the document is empty.
15244+
* @throws `ConvertToPdfProtectedWorkbook` Thrown if the document is protected.
15245+
* @throws `ExternalApiTimeout` Thrown if the API reaches the timeout limit of 30 seconds.
1524715246
*/
1524815247
function convertToPdf(): string;
1524915248

1525015249
/**
1525115250
* Downloads a specified file to the default download location specified by the local machine.
15252-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1525315251
* @param fileProperties The file to download.
15254-
* @throws DownloadFileNameMissing The error thrown if the name is empty.
15255-
* @throws DownloadFileContentMissing The error thrown if the content is empty.
15256-
* @throws DownloadFileInvalidExtension The error thrown if the file name extension is not ".txt" or ".pdf".
15257-
* @throws ExternalApiTimeout The error thrown if the API reaches the timeout limit of 30 seconds.
15252+
* @throws `DownloadFileNameMissing` Thrown if the name is empty.
15253+
* @throws `DownloadFileContentMissing` Thrown if the content is empty.
15254+
* @throws `DownloadFileInvalidExtension` Thrown if the file name extension is not ".txt" or ".pdf".
15255+
* @throws `ExternalApiTimeout` Thrown if the API reaches the timeout limit of 30 seconds.
1525815256
*/
15259-
function downloadFile(fileProperties: FileProperties): void;
15257+
function downloadFile(fileProperties: DownloadFileProperties): void;
1526015258

1526115259
/**
1526215260
* The file to download.
15263-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1526415261
*/
15265-
export interface FileProperties {
15262+
export interface DownloadFileProperties {
1526615263
/**
1526715264
* The name of the file once downloaded. The file extension determines the type of the file. Supported extensions are ".txt" and ".pdf". Default is ".txt".
15268-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1526915265
*/
1527015266
name: string;
1527115267

1527215268
/**
1527315269
* The content of the file.
15274-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1527515270
*/
1527615271
content: string;
1527715272
}
1527815273

1527915274
/**
1528015275
* Send an email with an Office Script. Use `MailProperties` to specify the content and recipients of the email.
15281-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1528215276
* @param message The properties that define the content and recipients of the email.
15283-
* @throws SendMailErrorMaxCalls The error thrown if the maximum number of API calls is exceeded. The limit is 100 API calls.
15284-
* @throws SendMailNoRecipient The error thrown if no recipient is specified.
15285-
* @throws SendMailInvalidEmail The error thrown if an invalid email address is provided.
15286-
* @throws SendMailExtensionNotSupported The error thrown if the attachment name extension is not ".txt" or ".pdf".
15287-
* @throws ExternalApiTimeout The error thrown if the API reaches the timeout limit of 30 seconds.
15277+
* @throws `SendMailMaxCalls` Thrown if the maximum number of API calls is exceeded. The limit is 100 API calls.
15278+
* @throws `SendMailNoRecipient` Thrown if no recipient is specified.
15279+
* @throws `SendMailInvalidEmail` Thrown if an invalid email address is provided.
15280+
* @throws `SendMailExtensionNotSupported` Thrown if the attachment name extension is not ".txt" or ".pdf".
15281+
* @throws `ExternalApiTimeout` Thrown if the API reaches the timeout limit of 30 seconds.
1528815282
*/
1528915283
function sendMail(mailProperties: MailProperties): void;
1529015284

1529115285
/**
1529215286
* The type of the content. Possible values are text or HTML.
15293-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1529415287
*/
1529515288
enum EmailContentType {
1529615289
/**
1529715290
* The email message body is in HTML format.
15298-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1529915291
*/
1530015292
html = "html",
1530115293

1530215294
/**
1530315295
* The email message body is in plain text format.
15304-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1530515296
*/
1530615297
text = "text",
1530715298
}
1530815299

1530915300
/**
1531015301
* The importance value of the email. Corresponds to "high", "normal", and "low" importance values available in the Outlook UI.
15311-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1531215302
*/
1531315303
enum EmailImportance {
1531415304
/**
1531515305
* Email is marked as low importance.
15316-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1531715306
*/
1531815307
low = "low",
1531915308

1532015309
/**
1532115310
* Email does not have any importance specified.
15322-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1532315311
*/
1532415312
normal = "normal",
1532515313

1532615314
/**
1532715315
* Email is marked as high importance.
15328-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1532915316
*/
1533015317
high = "high",
1533115318
}
@@ -15334,83 +15321,69 @@ declare namespace OfficeScript {
1533415321
* The attachment to send with the email.
1533515322
* A value must be specified for at least one of the `to`, `cc`, or `bcc` parameters.
1533615323
* If no recipient is specified, the following error is shown: "The message has no recipient. Please enter a value for at least one of the "to", "cc", or "bcc" parameters."
15337-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1533815324
*/
1533915325
export interface EmailAttachment {
1534015326
/**
1534115327
* The text that is displayed below the icon representing the attachment. This string doesn't need to match the file name.
15342-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1534315328
*/
1534415329
name: string;
1534515330
/**
1534615331
* The contents of the file.
15347-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1534815332
*/
1534915333
content: string;
1535015334
}
1535115335

1535215336
/**
1535315337
* The properties of the email to be sent.
15354-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1535515338
*/
1535615339
export interface MailProperties {
1535715340
/**
1535815341
* The subject of the email. Optional.
15359-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1536015342
*/
1536115343
subject?: string;
1536215344

1536315345
/**
1536415346
* The content of the email. Optional.
15365-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1536615347
*/
1536715348
content?: string;
1536815349

1536915350
/**
1537015351
* The type of the content in the email. Possible values are text or HTML. Optional.
15371-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1537215352
*/
1537315353
contentType?: EmailContentType;
1537415354

1537515355
/**
1537615356
* The importance of the email. The possible values are `low`, `normal`, and `high`. Default value is `normal`. Optional.
15377-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1537815357
*/
1537915358
importance?: EmailImportance;
1538015359

1538115360
/**
1538215361
* The direct recipient or recipients of the email. Optional.
15383-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1538415362
*/
1538515363
to?: string | string[];
1538615364

1538715365
/**
1538815366
* The carbon copy (CC) recipient or recipients of the email. Optional.
15389-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1539015367
*/
1539115368
cc?: string | string[];
1539215369

1539315370
/**
1539415371
* The blind carbon copy (BCC) recipient or recipients of the email. Optional.
15395-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1539615372
*/
1539715373
bcc?: string | string[];
1539815374

1539915375
/**
1540015376
* A file (such as a text file or Excel workbook) attached to a message. Optional.
15401-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1540215377
*/
1540315378
attachments?: EmailAttachment | EmailAttachment[];
1540415379
}
1540515380

1540615381
/**
1540715382
* Metadata about the script.
15408-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1540915383
*/
1541015384
namespace Metadata {
1541115385
/**
1541215386
* Get the name of the currently running script.
15413-
* @beta This API is in preview and may change based on feedback. Do not use this API in a production environment.
1541415387
*/
1541515388
function getScriptName(): string;
1541615389
}

0 commit comments

Comments
 (0)