Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Excel.CellValue type
- Package:
- excel
Represents the value in a cell.
export type CellValue = (ArrayCellValue | BooleanCellValue | DoubleCellValue | EntityCellValue | EmptyCellValue | ErrorCellValue | ExternalCodeServiceObjectCellValue | FormattedNumberCellValue | FunctionCellValue | LinkedEntityCellValue | LocalImageCellValue | ReferenceCellValue | StringCellValue | ValueTypeNotAvailableCellValue | WebImageCellValue) & CellValueExtraProperties;
Remarks
Used by
- Excel.ArrayCellValue: elements
- Excel.ChangedEventDetail: valueAsJsonAfter, valueAsJsonBefore
- Excel.ExternalCodeServiceObjectCellValue: preview
- Excel.NamedItem: valueAsJson, valueAsJsonLocal
- Excel.NamedItemArrayValues: valuesAsJson, valuesAsJsonLocal
- Excel.Range: valuesAsJson, valuesAsJsonLocal
- Excel.RangeView: valuesAsJson, valuesAsJsonLocal
- Excel.TableColumn: valuesAsJson, valuesAsJsonLocal
- Excel.TableColumnCollection: addAsJson
- Excel.TableRow: valuesAsJson, valuesAsJsonLocal
- Excel.TableRowCollection: addAsJson
Learn more about the types in this type alias through the following links.
Excel.ArrayCellValue, Excel.BooleanCellValue, Excel.DoubleCellValue, Excel.EntityCellValue, Excel.EmptyCellValue, Excel.ErrorCellValue, Excel.ExternalCodeServiceObjectCellValue, Excel.FormattedNumberCellValue, Excel.FunctionCellValue, Excel.LinkedEntityCellValue, Excel.LocalImageCellValue, Excel.ReferenceCellValue, Excel.StringCellValue, Excel.ValueTypeNotAvailableCellValue, Excel.WebImageCellValue, Excel.CellValueExtraProperties
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-web-image.yaml
// This function inserts a web image into the currently selected cell.
await Excel.run(async (context) => {
// Retrieve image data from the task pane and then clear the input fields.
const imageUrl = (document.getElementById("url") as HTMLInputElement).value;
const imageAltText = (document.getElementById("alt-text") as HTMLInputElement).value;
clearForm();
// Load the active cell.
const activeCell = context.workbook.getActiveCell();
activeCell.load();
await context.sync();
if (!imageUrl) {
console.log("Please enter an image URL.");
return;
}
// Create a web image object and assign the image details.
const webImage: Excel.WebImageCellValue = {
type: "WebImage", /* The string equivalent of `Excel.CellValueType.webImage`. */
address: imageUrl,
altText: imageAltText
};
// Insert web image into the active cell.
activeCell.valuesAsJson = [[webImage]];
await context.sync();
});
Office Add-ins
Feedback
Was this page helpful?
