📘range.setNumberFormat()
此指令主要是用來設定「儲存格值的格式」(數字、文字、日期等),但指令名稱取得實在很糟糕。
// text
range.setNumberFormat("@");
// date format
range.setNumberFormat("M/d/yy");
// Money format
range.setNumberFormat("$#,##0.00;$(#,##0.00)");
common syntax characters for custom number format:
0
A digit in the number. An insignificant 0 will appear in the results.
#
A digit in the number. An insignificant 0 will not appear in the results.
?
A digit in the number. An insignificant 0 will appear as a space in the results.
$
Formats numbers as a dollar value.
.(period)
Formats numbers with a decimal point.
,(comma)
Formats numbers with a thousands separator.
/
Formats numbers as a fraction.
%
Formats numbers as a percent
E
Formats numbers as an exponent.
"text"
Adds text to the formula. Insert the desired text within quotations for it to appear.
@
Displays text entered into a cell.
*
Repeats the following character to fill in the remaining space in the cell.
_ (underscore)
Adds a space equal in width to the following character.
Chris Black ⟩ Cell Number Formatting with Google Apps Script ⭐️
ConditionalFormatRule - 設定條件格式。
Last updated
Was this helpful?