Office.GetSelectedDataOptions interface
Provides options for customizing what data is returned and how it is formatted.
Remarks
Examples
/* Set the selection options. These will:
- Pass the string "myContext" to the callback.
- Include both visible and hidden data.
- Return the formatted values of the selection
(for an Excel date, 1/1/2023 instead of 44928).
*/
const options: Office.GetSelectedDataOptions = {
asyncContext: "myContext",
filterType: Office.FilterType.All,
valueFormat: Office.ValueFormat.Formatted
}
// Get the selected data in the Office document as text.
Office.context.document.getSelectedDataAsync(
Office.CoercionType.Text,
options,
(asyncResult) => {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
console.error(`${asyncResult.asyncContext}: asyncResult.error.message`);
} else {
console.log(`The selected data is "${asyncResult.value}".`);
}
});
Properties
| async |
A user-defined item of any type that is returned, unchanged, in the asyncContext property of the AsyncResult object that is passed to a callback. |
| filter |
Specify whether to get only the visible (that is, filtered-in) data or all the data. Useful when filtering data. Use Office.FilterType or string equivalent. This parameter is ignored in Word documents. |
| value |
Specify whether the data is formatted. Use Office.ValueFormat or string equivalent. |
Property Details
asyncContext
A user-defined item of any type that is returned, unchanged, in the asyncContext property of the AsyncResult object that is passed to a callback.
asyncContext?: any
Property Value
any
filterType
Specify whether to get only the visible (that is, filtered-in) data or all the data. Useful when filtering data. Use Office.FilterType or string equivalent. This parameter is ignored in Word documents.
filterType?: Office.FilterType | string
Property Value
Office.FilterType | string
valueFormat
Specify whether the data is formatted. Use Office.ValueFormat or string equivalent.
valueFormat?: Office.ValueFormat | string
Property Value
Office.ValueFormat | string