Excel.WebImageCellValue interface

インターネットからダウンロードしたイメージを含むセルの値を表します。

注釈

[ API セット: ExcelApi 1.16 ]

プロパティ

address

イメージのダウンロード元となる URL を表します。 このイメージは、HTTPS をサポートするサーバーでホストされている必要があります。

altText

アクセシビリティ シナリオで使用できる代替テキストを表し、画像が何を表すのかを表します。

attribution

このイメージを使用するためのソースとライセンスの要件を説明する属性情報を表します。

basicType

この値を持つセルの によって Range.valueTypes 返される値を表します。

basicValue

この値を持つセルの によって Range.values 返される値を表します。 プロパティを valuesAsJson 介してアクセスすると、この文字列値は en-US ロケールと一致します。 プロパティを valuesAsJsonLocal 介してアクセスすると、この文字列値はユーザーの表示ロケールと一致します。

provider

イメージを提供したエンティティまたは個人を表す情報を表します。 この情報は、イメージ カードのブランド化に使用できます。

relatedImagesAddress

この WebImageCellValueに関連すると見なされる画像を含む Web ページの URL を表します。

type

このセル値の型を表します。

プロパティの詳細

address

イメージのダウンロード元となる URL を表します。 このイメージは、HTTPS をサポートするサーバーでホストされている必要があります。

address: string;

プロパティ値

string

注釈

[ API セット: ExcelApi 1.16 ]

// 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 retrieves the image URL from the selected cell and opens that image in a new browser tab.
await Excel.run(async (context) => {
  // Load the active cell information.
  const activeCell = context.workbook.getActiveCell();
  activeCell.load("valuesAsJson");
  await context.sync();

  // Get image URL from the active cell.
  const values = activeCell.valuesAsJson;
  const webImageData = values[0][0] as Excel.WebImageCellValue;
  const webImageUrl = webImageData.address;

  if (!webImageUrl) {
    console.log("The selected cell is missing an image URL. Select a cell that contains an image.");
    return;
  }

  // Open the image URL in a new browser tab.
  const tab = window.open(webImageData.address, "_blank");
});

altText

アクセシビリティ シナリオで使用できる代替テキストを表し、画像が何を表すのかを表します。

altText?: string;

プロパティ値

string

注釈

[ API セット: ExcelApi 1.16 ]

attribution

このイメージを使用するためのソースとライセンスの要件を説明する属性情報を表します。

attribution?: CellValueAttributionAttributes[];

プロパティ値

注釈

[ API セット: ExcelApi 1.16 ]

basicType

この値を持つセルの によって Range.valueTypes 返される値を表します。

basicType?: RangeValueType.error | "Error";

プロパティ値

error | "Error"

注釈

[ API セット: ExcelApi 1.16 ]

basicValue

この値を持つセルの によって Range.values 返される値を表します。 プロパティを valuesAsJson 介してアクセスすると、この文字列値は en-US ロケールと一致します。 プロパティを valuesAsJsonLocal 介してアクセスすると、この文字列値はユーザーの表示ロケールと一致します。

basicValue?: "#VALUE!" | string;

プロパティ値

"#VALUE!" | string

注釈

[ API セット: ExcelApi 1.16 ]

provider

イメージを提供したエンティティまたは個人を表す情報を表します。 この情報は、イメージ カードのブランド化に使用できます。

provider?: CellValueProviderAttributes;

プロパティ値

注釈

[ API セット: ExcelApi 1.16 ]

relatedImagesAddress

この WebImageCellValueに関連すると見なされる画像を含む Web ページの URL を表します。

relatedImagesAddress?: string;

プロパティ値

string

注釈

[ API セット: ExcelApi 1.16 ]

type

このセル値の型を表します。

type: CellValueType.webImage | "WebImage";

プロパティ値

webImage | "WebImage"

注釈

[ API セット: ExcelApi 1.16 ]

// 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 = $("#url").val() as string;
  const imageAltText = $("#alt-text").val() as string;
  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();
});