Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Office.ValueFormat enum
- Package:
- office
Specifies whether values, such as numbers and dates, returned by the invoked method are returned with their formatting applied.
Remarks
For example, if the valueFormat parameter is specified as "formatted", a number formatted as currency, or a date formatted as mm/dd/yy in the Office application will have its formatting preserved. If the valueFormat parameter is specified as "unformatted", a date will be returned in its underlying sequential serial number form.
Used by
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}".`);
}
});
Fields
| Formatted | Return formatted data. |
| Unformatted | Return unformatted data. |
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Office Add-ins
Feedback
Was this page helpful?
