Class TextStyle
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
TextStyle
סגנון הטקסט שעבר רינדור בתא.
לסגנונות טקסט יכול להיות RichTextValue
תואם. אם ה-RichTextValue
משתרע על פני כמה רצפי טקסט שיש להם ערכים שונים לשיטת קריאה נתונה של סגנון טקסט, השיטה מחזירה את הערך null
. כדי למנוע זאת, צריך לשלוח שאילתה לגבי סגנונות טקסט באמצעות הערכים של טקסט עשיר שמוחזרים על ידי השיטה RichTextValue.getRuns()
.
Methods
שיטה | סוג הערך המוחזר | תיאור קצר |
copy() | TextStyleBuilder | יצירת הכלי ליצירת סגנון טקסט שמאופיין בערכי סגנון הטקסט הזה. |
getFontFamily() | String | הפונקציה מקבלת את משפחת הגופנים של הטקסט. |
getFontSize() | Integer | הפונקציה מקבלת את גודל הגופן של הטקסט בנקודות. |
getForegroundColorObject() | Color | הפונקציה מקבלת את צבע הגופן של הטקסט. |
isBold() | Boolean | הפונקציה מקבלת את הערך 'כן' או 'לא', בהתאם לכך שהטקסט מודגש או לא. |
isItalic() | Boolean | הפונקציה מקבלת את הערך 'כן' או 'לא', בהתאם לכך שהטקסט בתא נטוי או לא. |
isStrikethrough() | Boolean | הפונקציה מקבלת את הערך 'כן' או 'לא', בהתאם לכך אם יש קו חוצה בתא או לא. |
isUnderline() | Boolean | הפונקציה מקבלת את הערך 'כן' או 'לא', בהתאם לכך אם התא מסומן בקו תחתון או לא. |
מסמכים מפורטים
copy()
יצירת הכלי ליצירת סגנון טקסט שמאופיין בערכי סגנון הטקסט הזה.
חזרה
TextStyleBuilder
— יצירת כלי לפי סגנון הטקסט הזה.
getFontFamily()
הפונקציה מקבלת את משפחת הגופנים של הטקסט. הפונקציה מחזירה את הערך null
אם משפחת הגופנים לא מוגדרת או אם ל-RichTextValue
התואם יש כמה ריצות עם משפחות גופנים שונות.
חזרה
String
– משפחת הגופן של הטקסט (לדוגמה, 'Arial') או null
.
getFontSize()
הפונקציה מקבלת את גודל הגופן של הטקסט בנקודות. הפונקציה מחזירה את הערך null
אם גודל הגופן לא מוגדר או אם ל-RichTextValue
התואם יש כמה רצפים עם גדלי גופן שונים.
חזרה
Integer
– גודל הגופן של הטקסט או null
.
getForegroundColorObject()
הפונקציה מקבלת את צבע הגופן של הטקסט. הפונקציה מחזירה את הערך null
אם צבע הגופן לא מוגדר או אם ל-RichTextValue
התואם יש כמה רצפים עם צבעי גופן שונים.
חזרה
Color
— צבע הגופן של הטקסט או null
.
isBold()
הפונקציה מקבלת את הערך 'כן' או 'לא', בהתאם לכך שהטקסט מודגש או לא. הפונקציה מחזירה את הערך null
אם הגדרת הגופן מודגש לא מוגדרת או אם ל-RichTextValue
התואם יש כמה רצפים עם הגדרות מודגש שונות.
חזרה
Boolean
— מציין אם התא מודגש או לא, או null
.
isItalic()
הפונקציה מקבלת את הערך 'כן' או 'לא', בהתאם לכך שהטקסט בתא נטוי או לא. הפונקציה מחזירה את הערך null
אם הגדרת הגופן הנטוי לא מוגדרת או אם ל-RichTextValue
התואם יש כמה רצפים עם הגדרות נטוי שונות.
חזרה
Boolean
– אם התא נטוי או לא, או null
.
isStrikethrough()
הפונקציה מקבלת את הערך 'כן' או 'לא', בהתאם לכך אם יש קו חוצה בתא או לא. הפונקציה מחזירה את הערך null
אם לא הוגדרה קו חוצה או אם ל-RichTextValue
התואם יש כמה רצפים עם הגדרות שונות של קו חוצה.
חזרה
Boolean
— אם יש קו חוצה בתא או לא, או null
.
isUnderline()
הפונקציה מקבלת את הערך 'כן' או 'לא', בהתאם לכך אם התא מסומן בקו תחתון או לא. הפונקציה מחזירה את הערך null
אם ההגדרה של קו תחתון לא מוגדרת או אם ל-RichTextValue
התואם יש כמה רצפים עם הגדרות שונות של קו תחתון.
חזרה
Boolean
— אם יש קו תחתון בתא או לא, או null
.
שיטות שהוצאו משימוש
getForegroundColor()
הוצא משימוש. הוחלף על ידי getForegroundColorObject()
הפונקציה מקבלת את צבע הגופן של הטקסט. הפונקציה מחזירה את הערך null
אם צבע הגופן לא מוגדר או אם ל-RichTextValue
התואם יש כמה רצפים עם צבעי גופן שונים.
חזרה
String
– צבע הגופן של הטקסט כערך CSS ב-hex (לדוגמה, #ff0000) או null
.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-26 (שעון UTC)."],[[["\u003cp\u003e\u003ccode\u003eTextStyle\u003c/code\u003e defines the rendered style of text within a cell in Google Sheets, encompassing attributes like font family, size, color, and formatting.\u003c/p\u003e\n"],["\u003cp\u003eIt can be linked to a \u003ccode\u003eRichTextValue\u003c/code\u003e for more complex formatting but may return \u003ccode\u003enull\u003c/code\u003e for style properties if the \u003ccode\u003eRichTextValue\u003c/code\u003e has multiple runs with differing styles.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use methods like \u003ccode\u003egetFontFamily()\u003c/code\u003e, \u003ccode\u003egetFontSize()\u003c/code\u003e, \u003ccode\u003eisBold()\u003c/code\u003e, etc., to retrieve specific style attributes of the text.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003eTextStyleBuilder\u003c/code\u003e can be created using the \u003ccode\u003ecopy()\u003c/code\u003e method to facilitate the construction of new text styles based on existing ones.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetForegroundColor()\u003c/code\u003e method is deprecated and should be replaced with \u003ccode\u003egetForegroundColorObject()\u003c/code\u003e to retrieve the font color as a \u003ccode\u003eColor\u003c/code\u003e object.\u003c/p\u003e\n"]]],["TextStyle defines the visual styling of text within a cell. It interacts with RichTextValue, which handles text segments with varied styles. Core actions include: `copy()` which creates a new TextStyleBuilder with the current style, and getter methods such as `getFontFamily()`, `getFontSize()`, `getForegroundColorObject()`, `isBold()`, `isItalic()`, `isStrikethrough()`, and `isUnderline()`, that each retrieve a specific text style property. Most getter methods may return `null` if the property is not set or varies within a RichTextValue.\n"],null,["# Class TextStyle\n\nTextStyle\n\nThe rendered style of text in a cell.\n\nText styles can have a corresponding [RichTextValue](/apps-script/reference/spreadsheet/rich-text-value). If the [RichTextValue](/apps-script/reference/spreadsheet/rich-text-value) spans multiple text runs that have different values for a given text style read\nmethod, the method returns `null`. To avoid this, query for text styles using the Rich Text\nvalues returned by the [RichTextValue.getRuns()](/apps-script/reference/spreadsheet/rich-text-value#getRuns()) method. \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------------|---------------------------------------------------------------------------|------------------------------------------------------------------------------|\n| [copy()](#copy()) | [TextStyleBuilder](/apps-script/reference/spreadsheet/text-style-builder) | Creates a text style builder initialized with the values of this text style. |\n| [getFontFamily()](#getFontFamily()) | `String` | Gets the font family of the text. |\n| [getFontSize()](#getFontSize()) | `Integer` | Gets the font size of the text in points. |\n| [getForegroundColorObject()](#getForegroundColorObject()) | [Color](/apps-script/reference/spreadsheet/color) | Gets the font color of the text. |\n| [isBold()](#isBold()) | `Boolean` | Gets whether or not the text is bold. |\n| [isItalic()](#isItalic()) | `Boolean` | Gets whether or not the cell is italic. |\n| [isStrikethrough()](#isStrikethrough()) | `Boolean` | Gets whether or not the cell has strikethrough. |\n| [isUnderline()](#isUnderline()) | `Boolean` | Gets whether or not the cell is underlined. |\n\n### Deprecated methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------|-------------|----------------------------------|\n| [getForegroundColor()](#getForegroundColor()) | `String` | Gets the font color of the text. |\n\nDetailed documentation\n----------------------\n\n### `copy()`\n\nCreates a text style builder initialized with the values of this text style.\n\n#### Return\n\n\n[TextStyleBuilder](/apps-script/reference/spreadsheet/text-style-builder) --- A builder from this text style.\n\n*** ** * ** ***\n\n### `get``Font``Family()`\n\nGets the font family of the text. Returns `null` if the font family isn't set or the\ncorresponding [RichTextValue](/apps-script/reference/spreadsheet/rich-text-value) has multiple runs with different font\nfamilies.\n\n#### Return\n\n\n`String` --- The font family of the text (for example, \"Arial\") or `null`.\n\n*** ** * ** ***\n\n### `get``Font``Size()`\n\nGets the font size of the text in points. Returns `null` if the font size isn't set or\nthe corresponding [RichTextValue](/apps-script/reference/spreadsheet/rich-text-value) has multiple runs with different font\nsizes.\n\n#### Return\n\n\n`Integer` --- The font size of the text or `null`.\n\n*** ** * ** ***\n\n### `get``Foreground``Color``Object()`\n\nGets the font color of the text. Returns `null` if the font color isn't set or the\ncorresponding [RichTextValue](/apps-script/reference/spreadsheet/rich-text-value) has multiple runs with different font\ncolors.\n\n#### Return\n\n\n[Color](/apps-script/reference/spreadsheet/color) --- The font color of the text or `null`.\n\n*** ** * ** ***\n\n### `is``Bold()`\n\nGets whether or not the text is bold. Returns `null` if bold isn't set or the\ncorresponding [RichTextValue](/apps-script/reference/spreadsheet/rich-text-value) has multiple runs with different bold\nsettings.\n\n#### Return\n\n\n`Boolean` --- Whether or not the cell is bold, or `null`.\n\n*** ** * ** ***\n\n### `is``Italic()`\n\nGets whether or not the cell is italic. Returns `null` if italic isn't set or the\ncorresponding [RichTextValue](/apps-script/reference/spreadsheet/rich-text-value) has multiple runs with different italic\nsettings.\n\n#### Return\n\n\n`Boolean` --- Whether or not the cell is italic, or `null`.\n\n*** ** * ** ***\n\n### `is``Strikethrough()`\n\nGets whether or not the cell has strikethrough. Returns `null` if strikethrough isn't set\nor the corresponding [RichTextValue](/apps-script/reference/spreadsheet/rich-text-value) has multiple runs with different\nstrikethrough settings.\n\n#### Return\n\n\n`Boolean` --- Whether or not the cell has strikethrough, or `null`.\n\n*** ** * ** ***\n\n### `is``Underline()`\n\nGets whether or not the cell is underlined. Returns `null` if underline isn't set or the\ncorresponding [RichTextValue](/apps-script/reference/spreadsheet/rich-text-value) has multiple runs with different underline\nsettings.\n\n#### Return\n\n\n`Boolean` --- Whether or not the cell is underlined, or `null`.\n\nDeprecated methods\n------------------\n\n### `get``Foreground``Color()`\n\n\n**Deprecated.** Replaced by [getForegroundColorObject()](#getForegroundColorObject())\n\nGets the font color of the text. Returns `null` if the font color isn't set or the\ncorresponding [RichTextValue](/apps-script/reference/spreadsheet/rich-text-value) has multiple runs with different font\ncolors.\n\n#### Return\n\n\n`String` --- The font color of the text as a hex CSS value (for example, \"#ff0000\") or `null`."]]