UNPKG

declarations

Version:

[![npm version](https://badge.fury.io/js/declarations.svg)](https://www.npmjs.com/package/declarations)

1,036 lines (993 loc) 654 kB
// Type definitions for Office.js // Project: http://dev.office.com // Definitions by: OfficeDev <https://github.com/OfficeDev> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /* office-js Copyright (c) Microsoft Corporation */ declare namespace Office { export var context: Context; /** * This method is called after the Office API was loaded. * @param reason Indicates how the app was initialized */ export function initialize(reason: InitializationReason): void; /** * Indicates if the large namespace for objects will be used or not. * @param useShortNamespace Indicates if 'true' that the short namespace will be used */ export function useShortNamespace(useShortNamespace: boolean): void; // Enumerations export enum AsyncResultStatus { /** * Operation succeeded */ Succeeded, /** * Operation failed, check error object */ Failed } export enum InitializationReason { /** * Indicates the app was just inserted in the document */ Inserted, /** * Indicates if the extension already existed in the document */ DocumentOpened } // Objects export interface AsyncResult { asyncContext: any; status: AsyncResultStatus; error: Error; value: any; } export interface Context { contentLanguage: string; displayLanguage: string; license: string; touchEnabled: boolean; ui: UI; requirements: { /** * Check if the specified requirement set is supported by the host Office application. * @param name - Set name. e.g.: "MatrixBindings". * @param minVersion - The minimum required version. */ isSetSupported(name: string, minVersion?: number): boolean; } } export interface Error { message: string; name: string; } export interface UI { /** * Displays a dialog to show or collect information from the user or to facilitate Web navigation. * @param startAddress Accepts the initial HTTPS Url that opens in the dialog. * @param options Optional. Accepts a DialogOptions object to define dialog behaviors. * @param callback Optional. Accepts a callback method to handle the dialog creation attempt. */ displayDialogAsync(startAddress: string, options?: DialogOptions, callback?: (result: AsyncResult) => void): void; /** * When called from an active add-in dialog, asynchronously closes the dialog. */ close(): void; /** * Synchronously delivers a message from the dialog to its parent add-in. * @param messageObject Accepts a message from the dialog to deliver to the add-in. */ messageParent(messageObject: any): void; } export interface DialogOptions { /** * Optional. Defines the width of the dialog as a percentage of the current display. Defaults to 99%. 250px minimum. */ height?: number, /** * Optional. Defines the height of the dialog as a percentage of the current display. Defaults to 99%. 150px minimum. */ width?: number, /** * Optional. Specifies whether the dialog can only display pages that have HTTPS URLs. */ requireHTTPS?: boolean, /** * Optional. Determines whether the dialog is safe to display within a Web frame. */ xFrameDenySafe?: boolean, } } declare module OfficeExtension { /** An abstract proxy object that represents an object in an Office document. You create proxy objects from the context (or from other proxy objects), add commands to a queue to act on the object, and then synchronize the proxy object state with the document by calling "context.sync()". */ class ClientObject { /** The request context associated with the object */ context: ClientRequestContext; /** Returns a boolean value for whether the corresponding object is null. You must call "context.sync()" before reading the isNull property. [Api set: ExcelApi 1.3 (Preview), WordApi 1.3] */ isNull: boolean; } } declare module OfficeExtension { interface LoadOption { select?: string | string[]; expand?: string | string[]; top?: number; skip?: number; } /** An abstract RequestContext object that facilitates requests to the host Office application. The "Excel.run" and "Word.run" methods provide a request context. */ class ClientRequestContext { constructor(url?: string); /** Collection of objects that are tracked for automatic adjustments based on surrounding changes in the document. */ trackedObjects: TrackedObjects; /** Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ load(object: ClientObject, option?: string | string[] | LoadOption): void; /** Adds a trace message to the queue. If the promise returned by "context.sync()" is rejected due to an error, this adds a ".traceMessages" array to the OfficeExtension.Error object, containing all trace messages that were executed. These messages can help you monitor the program execution sequence and detect the cause of the error. */ trace(message: string): void; /** Synchronizes the state between JavaScript proxy objects and the Office document, by executing instructions queued on the request context and retrieving properties of loaded Office objects for use in your code. This method returns a promise, which is resolved when the synchronization is complete. */ sync<T>(passThroughValue?: T): IPromise<T>; } } declare module OfficeExtension { /** Contains the result for methods that return primitive types. The object's value property is retrieved from the document after "context.sync()" is invoked. */ class ClientResult<T> { /** The value of the result that is retrieved from the document after "context.sync()" is invoked. */ value: T; } } declare module OfficeExtension { /** The error object returned by "context.sync()", if a promise is rejected due to an error while processing the request. */ class Error { /** Error name: "OfficeExtension.Error".*/ name: string; /** The error message passed through from the host Office application. */ message: string; /** Stack trace, if applicable. */ stack: string; /** Error code string, such as "InvalidArgument". */ code: string; /** Trace messages (if any) that were added via a "context.trace()" invocation before calling "context.sync()". If there was an error, this contains all trace messages that were executed before the error occurred. These messages can help you monitor the program execution sequence and detect the case of the error. */ traceMessages: Array<string>; /** Debug info, if applicable. The ".errorLocation" property can describe the object and method or property that caused the error. */ debugInfo: { /** If applicable, will return the object type and the name of the method or property that caused the error. */ errorLocation?: string; }; } } declare module OfficeExtension { class ErrorCodes { static accessDenied: string; static generalException: string; static activityLimitReached: string; static invalidObjectPath: string; static propertyNotLoaded: string; static valueNotLoaded: string; static invalidRequestContext: string; static invalidArgument: string; static runMustReturnPromise: string; static cannotRegisterEvent: string; } } declare module OfficeExtension { /** An IPromise object that represents a deferred interaction with the host Office application. */ interface IPromise<R> { /** * This method will be called once the previous promise has been resolved. * Both the onFulfilled on onRejected callbacks are optional. * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. */ then<U>(onFulfilled?: (value: R) => IPromise<U>, onRejected?: (error: any) => IPromise<U>): IPromise<U>; /** * This method will be called once the previous promise has been resolved. * Both the onFulfilled on onRejected callbacks are optional. * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. */ then<U>(onFulfilled?: (value: R) => IPromise<U>, onRejected?: (error: any) => U): IPromise<U>; /** * This method will be called once the previous promise has been resolved. * Both the onFulfilled on onRejected callbacks are optional. * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. */ then<U>(onFulfilled?: (value: R) => IPromise<U>, onRejected?: (error: any) => void): IPromise<U>; /** * This method will be called once the previous promise has been resolved. * Both the onFulfilled on onRejected callbacks are optional. * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. */ then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => IPromise<U>): IPromise<U>; /** * This method will be called once the previous promise has been resolved. * Both the onFulfilled on onRejected callbacks are optional. * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. */ then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): IPromise<U>; /** * This method will be called once the previous promise has been resolved. * Both the onFulfilled on onRejected callbacks are optional. * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. */ then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): IPromise<U>; /** * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. * @param onRejected function to be called if or when the promise rejects. */ catch<U>(onRejected?: (error: any) => IPromise<U>): IPromise<U>; /** * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. * @param onRejected function to be called if or when the promise rejects. */ catch<U>(onRejected?: (error: any) => U): IPromise<U>; /** * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. * @param onRejected function to be called if or when the promise rejects. */ catch<U>(onRejected?: (error: any) => void): IPromise<U>; } /** An Promise object that represents a deferred interaction with the host Office application. The publically-consumable OfficeExtension.Promise is available starting in ExcelApi 1.2 and WordApi 1.2. Promises can be chained via ".then", and errors can be caught via ".catch". Remember to always use a ".catch" on the outer promise, and to return intermediary promises so as not to break the promise chain. When a "native" Promise implementation is available, OfficeExtension.Promise will switch to use the native Promise instead. */ export class Promise<R> implements IPromise<R> { /** * Creates a new promise based on a function that accepts resolve and reject handlers. */ constructor(func: (resolve : (value?: R | IPromise<R>) => void, reject: (error?: any) => void) => void); /** * Creates a promise that resolves when all of the child promises resolve. */ static all<U>(promises: OfficeExtension.IPromise<U>[]): IPromise<U[]>; /** * Creates a promise that is resolved. */ static resolve<U>(value: U): IPromise<U>; /** * Creates a promise that is rejected. */ static reject<U>(error: any): IPromise<U>; /* This method will be called once the previous promise has been resolved. * Both the onFulfilled on onRejected callbacks are optional. * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. */ then<U>(onFulfilled?: (value: R) => IPromise<U>, onRejected?: (error: any) => IPromise<U>): IPromise<U>; /** * This method will be called once the previous promise has been resolved. * Both the onFulfilled on onRejected callbacks are optional. * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. */ then<U>(onFulfilled?: (value: R) => IPromise<U>, onRejected?: (error: any) => U): IPromise<U>; /** * This method will be called once the previous promise has been resolved. * Both the onFulfilled on onRejected callbacks are optional. * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. */ then<U>(onFulfilled?: (value: R) => IPromise<U>, onRejected?: (error: any) => void): IPromise<U>; /** * This method will be called once the previous promise has been resolved. * Both the onFulfilled on onRejected callbacks are optional. * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. */ then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => IPromise<U>): IPromise<U>; /** * This method will be called once the previous promise has been resolved. * Both the onFulfilled on onRejected callbacks are optional. * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. */ then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): IPromise<U>; /** * This method will be called once the previous promise has been resolved. * Both the onFulfilled on onRejected callbacks are optional. * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. */ then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): IPromise<U>; /** * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. * @param onRejected function to be called if or when the promise rejects. */ catch<U>(onRejected?: (error: any) => IPromise<U>): IPromise<U>; /** * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. * @param onRejected function to be called if or when the promise rejects. */ catch<U>(onRejected?: (error: any) => U): IPromise<U>; /** * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. * @param onRejected function to be called if or when the promise rejects. */ catch<U>(onRejected?: (error: any) => void): IPromise<U>; } } declare module OfficeExtension { /** Collection of tracked objects, contained within a request context. See "context.trackedObjects" for more information. */ class TrackedObjects { /** Track a new object for automatic adjustment based on surrounding changes in the document. Only some object types require this. If you are using an object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created. */ add(object: ClientObject): void; /** Track a new object for automatic adjustment based on surrounding changes in the document. Only some object types require this. If you are using an object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created. */ add(objects: ClientObject[]): void; /** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect. */ remove(object: ClientObject): void; /** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect. */ remove(objects: ClientObject[]): void; } } declare module OfficeExtension { export class EventHandlers<T> { constructor(context: ClientRequestContext, parentObject: ClientObject, name: string, eventInfo: EventInfo<T>); add(handler: (args: T) => IPromise<any>): EventHandlerResult<T>; remove(handler: (args: T) => IPromise<any>): void; removeAll(): void; } export class EventHandlerResult<T> { constructor(context: ClientRequestContext, handlers: EventHandlers<T>, handler: (args: T) => IPromise<any>); remove(): void; } export interface EventInfo<T> { registerFunc: (callback: (args: any) => void) => IPromise<any>; unregisterFunc: (callback: (args: any) => void) => IPromise<any>; eventArgsTransformFunc: (args: any) => IPromise<T>; } } declare namespace Office { /** * Returns a promise of an object described in the expression. Callback is invoked only if method fails. * @param expression The object to be retrieved. Example "bindings#BindingName", retrieves a binding promise for a binding named 'BindingName' * @param callback The optional callback method */ export function select(expression: string, callback?: (result: AsyncResult) => void): Binding; // Enumerations export enum ActiveView { Read, Edit } export enum BindingType { /** * Text based Binding */ Text, /** * Matrix based Binding */ Matrix, /** * Table based Binding */ Table } export enum CoercionType { /** * Coerce as Text */ Text, /** * Coerce as Matrix */ Matrix, /** * Coerce as Table */ Table, /** * Coerce as HTML */ Html, /** * Coerce as Office Open XML */ Ooxml, /** * Coerce as JSON object containing an array of the ids, titles, and indexes of the selected slides. */ SlideRange, /** * Coerce as Image */ Image } export enum DocumentMode { /** * Document in Read Only Mode */ ReadOnly, /** * Document in Read/Write Mode */ ReadWrite } export enum EventType { /** * Occurs when the user changes the current view of the document. */ ActiveViewChanged, /** * Triggers when a binding level data change happens */ BindingDataChanged, /** * Triggers when a binding level selection happens */ BindingSelectionChanged, /** * Triggers when a document level selection happens */ DocumentSelectionChanged, /** * Triggers when a customXmlPart node was deleted */ NodeDeleted, /** * Triggers when a customXmlPart node was inserted */ NodeInserted, /** * Triggers when a customXmlPart node was replaced */ NodeReplaced, /** * Triggers when settings change in a co-Auth session. */ SettingsChanged, /** * Triggers when a Task selection happens in Project. */ TaskSelectionChanged, /** * Triggers when a Resource selection happens in Project. */ ResourceSelectionChanged, /** * Triggers when a View selection happens in Project. */ ViewSelectionChanged } export enum FileType { /** * Returns the file as plain text */ Text, /** * Returns the file as a byte array */ Compressed, /** * Returns the file in PDF format as a byte array */ Pdf } export enum FilterType { /** * Returns all items */ All, /** * Returns only visible items */ OnlyVisible } export enum GoToType { /** * Goes to a binding object using the specified binding id. */ Binding, /** * Goes to a named item using that item's name. * In Excel, you can use any structured reference for a named range or table: "Worksheet2!Table1" */ NamedItem, /** * Goes to a slide using the specified id. */ Slide, /** * Goes to the specified index by slide number or enum Office.Index */ Index } export enum Index { First, Last, Next, Previous } export enum SelectionMode { Default, Selected, None } export enum ValueFormat { /** * Returns items without format */ Unformatted, /** * Returns items with format */ Formatted } // Objects export interface Binding { document: Document; /** * Id of the Binding */ id: string; type: BindingType; /** * Adds an event handler to the object using the specified event type. * @param eventType The event type. For binding it can be 'bindingDataChanged' and 'bindingSelectionChanged' * @param handler The name of the handler * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ addHandlerAsync(eventType: EventType, handler: any, options?: any, callback?: (result: AsyncResult) => void): void; /** * Returns the current selection. * @param options Syntax example: {coercionType: 'matrix,'valueFormat: 'formatted', filterType:'all'} * coercionType: The expected shape of the selection. If not specified returns the bindingType shape. Use Office.CoercionType or text value. * valueFormat: Get data with or without format. Use Office.ValueFormat or text value. * startRow: Used in partial get for table/matrix. Indicates the start row. * startColumn: Used in partial get for table/matrix. Indicates the start column. * rowCount: Used in partial get for table/matrix. Indicates the number of rows from the start row. * columnCount: Used in partial get for table/matrix. Indicates the number of columns from the start column. * filterType: Get the visible or all the data. Useful when filtering data. Use Office.FilterType or text value. * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getDataAsync(options?: any, callback?: (result: AsyncResult) => void): void; /** * Removes an event handler from the object using the specified event type. * @param eventType The event type. For binding can be 'bindingDataChanged' and 'bindingSelectionChanged' * @param options Syntax example: {handler:eventHandler} * handler: Indicates a specific handler to be removed, if not specified all handlers are removed * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ removeHandlerAsync(eventType: EventType, options?: any, callback?: (result: AsyncResult) => void): void; /** * Writes the specified data into the current selection. * @param data The data to be set. Either a string or value, 2d array or TableData object * @param options Syntax example: {coercionType:Office.CoercionType.Matrix} or {coercionType: 'matrix'} * coercionType: Explicitly sets the shape of the data object. Use Office.CoercionType or text value. If not supplied is inferred from the data type. * startRow: Used in partial set for table/matrix. Indicates the start row. * startColumn: Used in partial set for table/matrix. Indicates the start column. * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ setDataAsync(data: TableData | any, options?: any, callback?: (result: AsyncResult) => void): void; } export interface Bindings { document: Document; /** * Creates a binding against a named object in the document * @param itemName Name of the bindable object in the document. For Example 'MyExpenses' table in Excel." * @param bindingType The Office BindingType for the data * @param options Syntax example: {id: "BindingID"} * id: Name of the binding, autogenerated if not supplied. * asyncContext: Object keeping state for the callback * columns: The string[] of the columns involved in the binding * @param callback The optional callback method */ addFromNamedItemAsync(itemName: string, bindingType: BindingType, options?: any, callback?: (result: AsyncResult) => void): void; /** * Create a binding by prompting the user to make a selection on the document. * @param bindingType The Office BindingType for the data * @param options addFromPromptAsyncOptions- e.g. {promptText: "Please select data", id: "mySales"} * promptText: Greet your users with a friendly word. * asyncContext: Object keeping state for the callback * id: Identifier. * sampleData: A TableData that gives sample table in the Dialog.TableData.Headers is [][] of string. * @param callback The optional callback method */ addFromPromptAsync(bindingType: BindingType, options?: any, callback?: (result: AsyncResult) => void): void; /** * Create a binding based on what the user's current selection. * @param bindingType The Office BindingType for the data * @param options addFromSelectionAsyncOptions- e.g. {id: "BindingID"} * id: Identifier. * asyncContext: Object keeping state for the callback * columns: The string[] of the columns involved in the binding * sampleData: A TableData that gives sample table in the Dialog.TableData.Headers is [][] of string. * @param callback The optional callback method */ addFromSelectionAsync(bindingType: BindingType, options?: any, callback?: (result: AsyncResult) => void): void; /** * Gets an array with all the binding objects in the document. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getAllAsync(options?: any, callback?: (result: AsyncResult) => void): void; /** * Retrieves a binding based on its Name * @param id The binding id * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getByIdAsync(id: string, options?: any, callback?: (result: AsyncResult) => void): void; /** * Removes the binding from the document * @param id The binding id * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ releaseByIdAsync(id: string, options?: any, callback?: (result: AsyncResult) => void): void; } export interface Context { document: Document; } export interface CustomXmlNode { baseName: string; namespaceUri: string; nodeType: string; /** * Gets the nodes associated with the xPath expression. * @param xPath The xPath expression * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getNodesAsync(xPath: string, options?: any, callback?: (result: AsyncResult) => void): void; /** * Gets the node value. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getNodeValueAsync(options?: any, callback?: (result: AsyncResult) => void): void; /** * Asynchronously gets the text of an XML node in a custom XML part. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getTextAsync(options?: any, callback?: (result: AsyncResult) => void): void; /** * Gets the node's XML. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getXmlAsync(options?: any, callback?: (result: AsyncResult) => void): void; /** * Sets the node value. * @param value The value to be set on the node * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ setNodeValueAsync(value: string, options?: any, callback?: (result: AsyncResult) => void): void; /** * Asynchronously sets the text of an XML node in a custom XML part. * @param text Required. The text value of the XML node. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ setTextAsync(text: string, options?: any, callback?: (result: AsyncResult) => void): void; /** * Sets the node XML. * @param xml The XML to be set on the node * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ setXmlAsync(xml: string, options?: any, callback?: (result: AsyncResult) => void): void; } export interface CustomXmlPart { builtIn: boolean; id: string; namespaceManager: CustomXmlPrefixMappings; /** * Adds an event handler to the object using the specified event type. * @param eventType The event type. For CustomXmlPartNode it can be 'nodeDeleted', 'nodeInserted' or 'nodeReplaced' * @param handler The name of the handler * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ addHandlerAsync(eventType: EventType, handler?: (result: any) => void, options?: any, callback?: (result: AsyncResult) => void): void; /** * Deletes the Custom XML Part. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ deleteAsync(options?: any, callback?: (result: AsyncResult) => void): void; /** * Gets the nodes associated with the xPath expression. * @param xPath The xPath expression * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getNodesAsync(xPath: string, options?: any, callback?: (result: AsyncResult) => void): void; /** * Gets the XML for the Custom XML Part. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getXmlAsync(options?: any, callback?: (result: AsyncResult) => void): void; /** * Removes an event handler from the object using the specified event type. * @param eventType The event type. For CustomXmlPartNode it can be 'nodeDeleted', 'nodeInserted' or 'nodeReplaced' * @param options Syntax example: {handler:eventHandler} * handler: Indicates a specific handler to be removed, if not specified all handlers are removed * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ removeHandlerAsync(eventType: EventType, options?: any, callback?: (result: AsyncResult) => void): void; } export interface CustomXmlParts { /** * Asynchronously adds a new custom XML part to a file. * @param xml The XML to add to the newly created custom XML part. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult. */ addAsync(xml: string, options?: any, callback?: (result: AsyncResult) => void): void; /** * Asynchronously gets the specified custom XML part by its id. * @param id The id of the custom XML part. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult. */ getByIdAsync(id: string, options?: any, callback?: (result: AsyncResult) => void): void; /** * Asynchronously gets the specified custom XML part(s) by its namespace. * @param ns The namespace to search. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult. */ getByNamespaceAsync(ns: string, options?: any, callback?: (result: AsyncResult) => void): void; } export interface CustomXmlPrefixMappings { /** * Adds a namespace. * @param prefix The namespace prefix * @param ns The namespace URI * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ addNamespaceAsync(prefix: string, ns: string, options?: any, callback?: (result: AsyncResult) => void): void; /** * Gets a namespace with the specified prefix * @param prefix The namespace prefix * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getNamespaceAsync(prefix: string, options?: any, callback?: (result: AsyncResult) => void): void; /** * Gets a prefix for the specified URI * @param ns The namespace URI * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getPrefixAsync(ns: string, options?: any, callback?: (result: AsyncResult) => void): void; } export interface Document { bindings: Bindings; customXmlParts: CustomXmlParts; mode: DocumentMode; settings: Settings; url: string; /** * Adds an event handler for the specified event type. * @param eventType The event type. For document can be 'DocumentSelectionChanged' * @param handler The name of the handler * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ addHandlerAsync(eventType: EventType, handler: any, options?: any, callback?: (result: AsyncResult) => void): void; /** * Returns the current view of the presentation. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getActiveViewAsync(options?: any, callback?: (result: AsyncResult) => void): void; /** * Gets the entire file in slices of up to 4MB. * @param fileType The format in which the file will be returned * @param options Syntax example: {sliceSize:1024} * sliceSize: Specifies the desired slice size (in bytes) up to 4MB. If not specified a default slice size of 4MB will be used. * @param callback The optional callback method */ getFileAsync(fileType: FileType, options?: any, callback?: (result: AsyncResult) => void): void; /** * Gets file properties of the current document. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getFilePropertiesAsync(options?: any, callback?: (result: AsyncResult) => void): void; /** * Returns the current selection. * @param coercionType The expected shape of the selection. * @param options Syntax example: {valueFormat: 'formatted', filterType:'all'} * valueFormat: Get data with or without format. Use Office.ValueFormat or text value. * filterType: Get the visible or all the data. Useful when filtering data. Use Office.FilterType or text value. * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getSelectedDataAsync(coercionType: CoercionType, options?: any, callback?: (result: AsyncResult) => void): void; /** * Goes to the specified object or location in the document. * @param id The identifier of the object or location to go to. * @param goToType The type of the location to go to. * @param options Syntax example: {asyncContext:context} * selectionMode: Use Office.SelectionMode or text value. * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ goToByIdAsync(id: string | number, goToType: GoToType, options?: any, callback?: (result: AsyncResult) => void): void; /** * Removes an event handler for the specified event type. * @param eventType The event type. For document can be 'DocumentSelectionChanged' * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * handler: The name of the handler. If not specified all handlers are removed * @param callback The optional callback method */ removeHandlerAsync(eventType: EventType, options?: any, callback?: (result: AsyncResult) => void): void; /** * Writes the specified data into the current selection. * @param data The data to be set. Either a string or value, 2d array or TableData object * @param options Syntax example: {coercionType:Office.CoercionType.Matrix} or {coercionType: 'matrix'} * coercionType: Explicitly sets the shape of the data object. Use Office.CoercionType or text value. If not supplied is inferred from the data type. * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ setSelectedDataAsync(data: string | TableData | any[][], options?: any, callback?: (result: AsyncResult) => void): void; } export interface File { size: number; sliceCount: number; /** * Closes the File. * @param callback The optional callback method */ closeAsync(callback?: (result: AsyncResult) => void): void; /** * Gets the specified slice. * @param sliceIndex The index of the slice to be retrieved * @param callback The optional callback method */ getSliceAsync(sliceIndex: number, callback?: (result: AsyncResult) => void): void; } export interface FileProperties { /** * File's URL */ url: string } export interface MatrixBinding extends Binding { columnCount: number; rowCount: number; } export interface Settings { /** * Adds an event handler for the object using the specified event type. * @param eventType The event type. For settings can be 'settingsChanged' * @param handler The name of the handler * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ addHandlerAsync(eventType: EventType, handler: any, options?: any, callback?: (result: AsyncResult) => void): void; /** * Retrieves the setting with the specified name. * @param settingName The name of the setting */ get(name: string): any; /** * Gets the latest version of the settings object. * @param callback The optional callback method */ refreshAsync(callback?: (result: AsyncResult) => void): void; /** * Removes the setting with the specified name. * @param settingName The name of the setting */ remove(name: string): void; /** * Removes an event handler for the specified event type. * @param eventType The event type. For settings can be 'settingsChanged' * @param options Syntax example: {handler:eventHandler} * handler: Indicates a specific handler to be removed, if not specified all handlers are removed * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ removeHandlerAsync(eventType: EventType, options?: any, callback?: (result: AsyncResult) => void): void; /** * Saves all settings. * @param options Syntax example: {overwriteIfStale:false} * overwriteIfStale: Indicates whether the setting will be replaced if stale. * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ saveAsync(callback?: (result: AsyncResult) => void): void; /** * Sets a value for the setting with the specified name. * @param settingName The name of the setting * @param value The value for the setting */ set(name: string, value: any): void; } export interface Slice { data: any; index: number; size: number; } export interface TableBinding extends Binding { columnCount: number; hasHeaders: boolean; rowCount: number; /** * Adds the specified columns to the table * @param tableData A TableData object with the headers and rows * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ addColumnsAsync(tableData: TableData | any[][], options?: any, callback?: (result: AsyncResult) => void): void; /** * Adds the specified rows to the table * @param rows A 2D array with the rows to add * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ addRowsAsync(rows: TableData | any[][], options?: any, callback?: (result: AsyncResult) => void): void; /** * Clears the table * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ deleteAllDataValuesAsync(options?: any, callback?: (result: AsyncResult) => void): void; /** * Clears formatting on the bound table. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ clearFormatsAsync(options?: any, callback?: (result: AsyncResult) => void): void; /** * Gets the formatting on specified items in the table. * @param cellReference An object literal containing name-value pairs that specify the range of cells to get formatting from. * @param formats An array specifying the format properties to get. * @param options Syntax example: {asyncContext:context} * asyncContext: Object keeping state for the callback * @param callback The optional callback method */ getFormatsAsync(cellReference?: any, formats?: any[], options?: any, callback?: (result: AsyncResult) => void): void; /** * Sets formatting on specified items and data in the table. * @param formatsInfo Array elements are themselves three-element arrays:[target, type, formats] * target: The identifier of the item to format. String. * type: The kind of item to format. String. * formats: An object literal containing a list of property name-value pairs that define the formatting to apply. *