Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/26 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/07/26 (UTC)."],[[["\u003cp\u003e\u003ccode\u003eTextStyleBuilder\u003c/code\u003e helps create custom text styles with various formatting options.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify font family, size, color, and styles like bold, italic, underline, and strikethrough.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods like \u003ccode\u003esetBold\u003c/code\u003e, \u003ccode\u003esetFontFamily\u003c/code\u003e, \u003ccode\u003esetFontSize\u003c/code\u003e, and others to define text attributes.\u003c/p\u003e\n"],["\u003cp\u003eUse the \u003ccode\u003ebuild()\u003c/code\u003e method to create a \u003ccode\u003eTextStyle\u003c/code\u003e object with your defined formatting.\u003c/p\u003e\n"],["\u003cp\u003eThis builder enables flexible and detailed control over text presentation in Google Apps Script.\u003c/p\u003e\n"]]],[],null,["TextStyleBuilder\n\nA builder for text styles. \n\nMethods\n\n| Method | Return type | Brief description |\n|---------------------------------------------------------------------|------------------------------------------------------------|-------------------------------------------------|\n| [build()](#build()) | [TextStyle](/apps-script/reference/spreadsheet/text-style) | Creates a text style from this builder. |\n| [setBold(bold)](#setBold(Boolean)) | [TextStyleBuilder](#) | Sets whether or not the text is bold. |\n| [setFontFamily(fontFamily)](#setFontFamily(String)) | [TextStyleBuilder](#) | Sets the text font family, such as \"Arial\". |\n| [setFontSize(fontSize)](#setFontSize(Integer)) | [TextStyleBuilder](#) | Sets the text font size in points. |\n| [setForegroundColor(cssString)](#setForegroundColor(String)) | [TextStyleBuilder](#) | Sets the text font color. |\n| [setForegroundColorObject(color)](#setForegroundColorObject(Color)) | [TextStyleBuilder](#) | Sets the text font color. |\n| [setItalic(italic)](#setItalic(Boolean)) | [TextStyleBuilder](#) | Sets whether or not the text is italic. |\n| [setStrikethrough(strikethrough)](#setStrikethrough(Boolean)) | [TextStyleBuilder](#) | Sets whether or not the text has strikethrough. |\n| [setUnderline(underline)](#setUnderline(Boolean)) | [TextStyleBuilder](#) | Sets whether or not the text is underlined. |\n\nDetailed documentation \n\n`build()` \nCreates a text style from this builder.\n\nReturn\n\n\n[TextStyle](/apps-script/reference/spreadsheet/text-style) --- A text style created from this builder.\n\n*** ** * ** ***\n\n`set``Bold(bold)` \nSets whether or not the text is bold.\n\nParameters\n\n| Name | Type | Description |\n|--------|-----------|----------------------------------|\n| `bold` | `Boolean` | Whether or not the text is bold. |\n\nReturn\n\n\n[TextStyleBuilder](#) --- The builder for chaining.\n\n*** ** * ** ***\n\n`set``Font``Family(fontFamily)` \nSets the text font family, such as \"Arial\".\n\nParameters\n\n| Name | Type | Description |\n|----------------|----------|--------------------------|\n| `font``Family` | `String` | The desired font family. |\n\nReturn\n\n\n[TextStyleBuilder](#) --- The builder for chaining.\n\n*** ** * ** ***\n\n`set``Font``Size(fontSize)` \nSets the text font size in points.\n\nParameters\n\n| Name | Type | Description |\n|--------------|-----------|------------------------|\n| `font``Size` | `Integer` | The desired font size. |\n\nReturn\n\n\n[TextStyleBuilder](#) --- The builder for chaining.\n\n*** ** * ** ***\n\n`set``Foreground``Color(cssString)` \nSets the text font color.\n\nParameters\n\n| Name | Type | Description |\n|---------------|----------|----------------------------------------------------------------------------|\n| `css``String` | `String` | The desired font color in CSS notation (such as `'#ffffff'` or `'white'`). |\n\nReturn\n\n\n[TextStyleBuilder](#) --- The builder for chaining.\n\n*** ** * ** ***\n\n`set``Foreground``Color``Object(color)` \nSets the text font color.\n\nParameters\n\n| Name | Type | Description |\n|---------|---------------------------------------------------|-------------------------|\n| `color` | [Color](/apps-script/reference/spreadsheet/color) | The desired font color. |\n\nReturn\n\n\n[TextStyleBuilder](#) --- The builder for chaining.\n\n*** ** * ** ***\n\n`set``Italic(italic)` \nSets whether or not the text is italic.\n\nParameters\n\n| Name | Type | Description |\n|----------|-----------|------------------------------------|\n| `italic` | `Boolean` | Whether or not the text is italic. |\n\nReturn\n\n\n[TextStyleBuilder](#) --- The builder for chaining.\n\n*** ** * ** ***\n\n`set``Strikethrough(strikethrough)` \nSets whether or not the text has strikethrough.\n\nParameters\n\n| Name | Type | Description |\n|-----------------|-----------|--------------------------------------------|\n| `strikethrough` | `Boolean` | Whether or not the text has strikethrough. |\n\nReturn\n\n\n[TextStyleBuilder](#) --- The builder for chaining.\n\n*** ** * ** ***\n\n`set``Underline(underline)` \nSets whether or not the text is underlined.\n\nParameters\n\n| Name | Type | Description |\n|-------------|-----------|----------------------------------------|\n| `underline` | `Boolean` | Whether or not the text is underlined. |\n\nReturn\n\n\n[TextStyleBuilder](#) --- The builder for chaining."]]