Class CellImageBuilder
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
CellImageBuilder
CellImage
의 빌더입니다. 이 빌더는 셀에 이미지를 추가하는 데 필요한 이미지 값을 만듭니다.
속성
속성 | 유형 | 설명 |
valueType | ValueType | 셀 이미지의 값 유형으로 ValueType.IMAGE 입니다. |
지원 중단된 메서드
메서드 | 반환 유형 | 간략한 설명 |
getUrl()
| String | 이미지의 소스 URL을 가져옵니다. |
자세한 문서
build()
셀에 이미지를 추가하는 데 필요한 이미지 값 유형을 만듭니다. 이미지 값은 소스 URL과 같이 빌더에 추가된 이미지 속성에서 빌드됩니다.
리턴
CellImage
: 셀에 추가할 이미지의 표현입니다.
getAltTextDescription()
이 이미지의 대체 텍스트 설명을 반환합니다.
리턴
String
: 대체 텍스트 설명입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getAltTextTitle()
이 이미지의 대체 텍스트 제목을 반환합니다.
리턴
String
: 대체 텍스트 제목입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getContentUrl()
Google에서 호스팅하는 이미지 URL을 반환합니다. 이 URL은 요청자의 계정으로 태그되므로 이 URL을 가진 모든 사용자가 원래 요청자로서 이미지에 액세스할 수 있습니다. 스프레드시트의 공유 설정이 변경되면 이미지에 액세스할 수 없게 될 수 있습니다. 반환된 URL은 잠시 후 만료됩니다.
const range = SpreadsheetApp.getActiveSpreadsheet().getRange("Sheet1!A1");
const value = range.getValue();
if (value.valueType == SpreadsheetApp.ValueType.IMAGE) {
console.log(value.getContentUrl());
}
리턴
String
: Google에서 호스팅하는 이미지의 URL입니다.
setAltTextDescription(description)
이 이미지의 대체 텍스트 설명을 설정합니다.
매개변수
이름 | 유형 | 설명 |
description | String | 이미지의 새 대체 텍스트 설명입니다. |
리턴
CellImage
: 체이닝에 이 이미지가 반환됩니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setAltTextTitle(title)
이 이미지의 대체 텍스트 제목을 설정합니다.
매개변수
이름 | 유형 | 설명 |
title | String | 이미지의 새 대체 텍스트 제목입니다. |
리턴
CellImage
: 체이닝에 이 이미지가 반환됩니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setSourceUrl(url)
이미지 소스 URL을 설정합니다.
매개변수
이름 | 유형 | 설명 |
url | String | 이미지의 URL입니다. |
리턴
CellImageBuilder
: 체이닝을 위한 이 빌더
toBuilder()
현재 이미지 속성을 기반으로 셀 이미지 빌더를 만듭니다. setSourceUrl(url)
를 사용하여 새 이미지의 소스 URL을 설정합니다. 그런 다음 Range.setValue(value)
또는 Range.setValues(values)
를 사용하여 셀에 추가할 수 있습니다.
const ss = SpreadsheetApp.getActiveSpreadsheet();
const range = ss.getRange("Sheet1!A1");
const value = range.getValue();
if (value.valueType == SpreadsheetApp.ValueType.IMAGE) {
const newImage =
value.toBuilder()
.setSourceUrl(
'https://www.gstatic.com/images/branding/productlogos/apps_script/v10/web-64dp/logo_apps_script_color_1x_web_64dp.png',
)
.build();
const newRange = ss.getRange("Sheet1!A2");
newRange.setValue(newImage);
}
리턴
CellImageBuilder
: 지정된 이미지 속성을 기반으로 이미지 값 유형을 만드는 빌더입니다.
지원 중단된 메서드
getUrl()
지원 중단되었습니다. 새로 삽입된 대부분의 이미지의 경우 소스 URL을 사용할 수 없습니다.
이미지의 소스 URL을 가져옵니다. URL을 사용할 수 없는 경우 빈 문자열을 반환합니다. 새로 삽입된 대부분의 이미지의 경우 이미지를 삽입하는 방법과 관계없이 소스 URL을 사용할 수 없습니다.
리턴
String
: 사용 가능한 경우 이미지의 소스 URL입니다. 그렇지 않으면 빈 문자열을 반환합니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003e\u003ccode\u003eCellImageBuilder\u003c/code\u003e facilitates the creation and manipulation of images within Google Sheets cells.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods for setting the image source, alt text, and retrieving a Google-hosted URL.\u003c/p\u003e\n"],["\u003cp\u003eYou can build a \u003ccode\u003eCellImage\u003c/code\u003e to insert into a cell using the \u003ccode\u003ebuild()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003etoBuilder()\u003c/code\u003e method enables modification of existing cell images and insertion into new cells.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetUrl()\u003c/code\u003e method is deprecated as it often returns an empty string for newly inserted images.\u003c/p\u003e\n"]]],["The `CellImageBuilder` facilitates adding images to spreadsheet cells. It constructs image values with `build()`, which requires a source URL set via `setSourceUrl()`. Alt text can be managed using `setAltTextDescription()` and `setAltTextTitle()`, and information can be retrieved by using `getAltTextDescription()` ,`getAltTextTitle()` and `getContentUrl()`. `toBuilder()` creates a new builder from an existing image. The value type for cell images is `ValueType.IMAGE`. A deprecated method, `getUrl()`, was used to retrieve source URLs.\n"],null,["# Class CellImageBuilder\n\nCellImageBuilder\n\nBuilder for [CellImage](#). This builder creates the image value needed to add an\nimage to a cell. \n\n### Properties\n\n| Property | Type | Description |\n|---------------|------------------------------------------------------------|-----------------------------------------------------------------|\n| `value``Type` | [ValueType](/apps-script/reference/spreadsheet/value-type) | The value type of the cell image, which is `Value``Type.IMAGE`. |\n\n### Methods\n\n| Method | Return type | Brief description |\n|----------------------------------------------------------------------|------------------------------------------------------------|---------------------------------------------------------------------|\n| [build()](#build()) | [CellImage](/apps-script/reference/spreadsheet/cell-image) | Creates the image value type needed to add an image to a cell. |\n| [getAltTextDescription()](#getAltTextDescription()) | `String` | Returns the alt text description for this image. |\n| [getAltTextTitle()](#getAltTextTitle()) | `String` | Returns the alt text title for this image. |\n| [getContentUrl()](#getContentUrl()) | `String` | Returns a Google-hosted URL to the image. |\n| [setAltTextDescription(description)](#setAltTextDescription(String)) | [CellImage](/apps-script/reference/spreadsheet/cell-image) | Sets the alt-text description for this image. |\n| [setAltTextTitle(title)](#setAltTextTitle(String)) | [CellImage](/apps-script/reference/spreadsheet/cell-image) | Sets the alt text title for this image. |\n| [setSourceUrl(url)](#setSourceUrl(String)) | [CellImageBuilder](#) | Sets the image source URL. |\n| [toBuilder()](#toBuilder()) | [CellImageBuilder](#) | Creates a cell image builder based on the current image properties. |\n\n### Deprecated methods\n\n| Method | Return type | Brief description |\n|-----------------------|-------------|------------------------------|\n| [getUrl()](#getUrl()) | `String` | Gets the image's source URL. |\n\nDetailed documentation\n----------------------\n\n### `build()`\n\nCreates the image value type needed to add an image to a cell. The image value is built from\nthe image properties added to the builder, such as the source URL.\n\n#### Return\n\n\n[CellImage](/apps-script/reference/spreadsheet/cell-image) --- A representation of the image to add to a cell.\n\n*** ** * ** ***\n\n### `get``Alt``Text``Description()`\n\nReturns the alt text description for this image.\n\n#### Return\n\n\n`String` --- The alt text description.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Alt``Text``Title()`\n\nReturns the alt text title for this image.\n\n#### Return\n\n\n`String` --- The alt text title.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Content``Url()`\n\nReturns a Google-hosted URL to the image. This URL is tagged with the account of the requester,\nso anyone with the URL effectively accesses the image as the original requester. Access to the\nimage might be lost if the spreadsheet's sharing settings change. The returned URL expires\nafter a short period of time.\n\n```javascript\nconst range = SpreadsheetApp.getActiveSpreadsheet().getRange(\"Sheet1!A1\");\nconst value = range.getValue();\nif (value.valueType == SpreadsheetApp.ValueType.IMAGE) {\n console.log(value.getContentUrl());\n}\n```\n\n#### Return\n\n\n`String` --- The Google-hosted URL of the image.\n\n*** ** * ** ***\n\n### `set``Alt``Text``Description(description)`\n\nSets the alt-text description for this image.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------------|----------|---------------------------------------------|\n| `description` | `String` | The new alt text description for the image. |\n\n#### Return\n\n\n[CellImage](/apps-script/reference/spreadsheet/cell-image) --- This image, for chaining.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `set``Alt``Text``Title(title)`\n\nSets the alt text title for this image.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|----------|---------------------------------------|\n| `title` | `String` | The new alt text title for the image. |\n\n#### Return\n\n\n[CellImage](/apps-script/reference/spreadsheet/cell-image) --- This image, for chaining.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `set``Source``Url(url)`\n\nSets the image source URL.\n\n#### Parameters\n\n| Name | Type | Description |\n|-------|----------|------------------------|\n| `url` | `String` | The URL for the image. |\n\n#### Return\n\n\n[CellImageBuilder](#) --- This builder, for chaining.\n\n*** ** * ** ***\n\n### `to``Builder()`\n\nCreates a cell image builder based on the current image properties. Use [setSourceUrl(url)](#setSourceUrl(String)) to set the source URL of the new image. Then you can add it to a\ncell using [Range.setValue(value)](/apps-script/reference/spreadsheet/range#setValue(Object)) or [Range.setValues(values)](/apps-script/reference/spreadsheet/range#setValues(Object)).\n\n```javascript\nconst ss = SpreadsheetApp.getActiveSpreadsheet();\nconst range = ss.getRange(\"Sheet1!A1\");\nconst value = range.getValue();\nif (value.valueType == SpreadsheetApp.ValueType.IMAGE) {\n const newImage =\n value.toBuilder()\n .setSourceUrl(\n 'https://www.gstatic.com/images/branding/productlogos/apps_script/v10/web-64dp/logo_apps_script_color_1x_web_64dp.png',\n )\n .build();\n const newRange = ss.getRange(\"Sheet1!A2\");\n newRange.setValue(newImage);\n}\n```\n\n#### Return\n\n\n[CellImageBuilder](#) --- A builder that creates an image value type based on the given image properties.\n\nDeprecated methods\n------------------\n\n### `get``Url()`\n\n\n**Deprecated.** For most newly inserted images, the source URL is unavailable.\n\nGets the image's source URL. Returns an empty string if the URL is unavailable. For most newly\ninserted images, the source URL is unavailable regardless how the image is inserted.\n\n#### Return\n\n\n`String` --- The image's source URL if available; returns an empty string otherwise.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`"]]