Office.CoercionType enum

Specifies how to coerce data returned or set by the invoked method.

Remarks

Application and platform support for each CoercionType is specified in the following requirement set descriptions.

Examples

// This function displays the currently selected text in the console.
// It uses the Common APIs.
function run() {
    Office.context.document.getSelectedDataAsync(Office.CoercionType.Text, (asyncResult) => {
        if (asyncResult.status === Office.AsyncResultStatus.Failed) {
            console.error(asyncResult.error.message);
        } else {
            console.log(`The selected data is "${asyncResult.value}".`);
        }
    });
}

Fields

Html

Return or set data as HTML.

Note: Only applies to data in add-ins for Word and Outlook add-ins for Outlook (compose mode).

Image

Data is returned or set as an image stream. Note: Only applies to data in Excel, Word, and PowerPoint.

Matrix

Return or set data as tabular data with no headers. Data is returned or set as an array of arrays containing one-dimensional runs of characters. For example, three rows of string values in two columns would be: [["R1C1", "R1C2"], ["R2C1", "R2C2"], ["R3C1", "R3C2"]].

Note: Only applies to data in Excel and Word.

Ooxml

Return or set data as Office Open XML.

Note: Only applies to data in Word.

SlideRange

Return a JSON object that contains an array of the IDs, titles, and indexes of the selected slides. For example, {"slides":[{"id":257,"title":"Slide 2","index":2},{"id":256,"title":"Slide 1","index":1}]} for a selection of two slides.

Note: Only applies to data in PowerPoint when calling the Document.getSelectedData method to get the current slide or selected range of slides.

Table

Return or set data as tabular data with optional headers. Data is returned or set as an array of arrays with optional headers.

Note: Only applies to data in Excel and Word.

Text

Return or set data as text (string). Data is returned or set as a one-dimensional run of characters.

XmlSvg

Data is returned or set as XML data containing an SVG image. Note: Only applies to data in Excel, Word, and PowerPoint.