دسترسی و تغییر محدودههای صفحهگسترده. یک محدوده میتواند یک سلول واحد در یک برگه یا گروهی از سلولهای مجاور در یک برگه باشد.
روشها
| روش | نوع بازگشتی | شرح مختصر |
|---|---|---|
activate() | Range | محدوده مشخص شده را به عنوان active range ، با سلول بالا سمت چپ در محدوده به عنوان current cell ، تنظیم میکند. |
activate As Current Cell() | Range | سلول مشخص شده را به عنوان current cell تنظیم میکند. |
add Developer Metadata(key) | Range | متادیتای توسعهدهنده را با کلید مشخصشده به محدوده اضافه میکند. |
add Developer Metadata(key, visibility) | Range | فرادادههای توسعهدهنده را با کلید و قابلیت مشاهده مشخصشده به محدوده اضافه میکند. |
add Developer Metadata(key, value) | Range | متادیتای توسعهدهنده را با کلید و مقدار مشخصشده به محدوده اضافه میکند. |
add Developer Metadata(key, value, visibility) | Range | فرادادههای توسعهدهنده را با کلید، مقدار و قابلیت مشاهدهی مشخصشده به محدوده اضافه میکند. |
apply Column Banding() | Banding | یک تم نواربندی ستون پیشفرض را به محدوده اعمال میکند. |
apply Column Banding(bandingTheme) | Banding | یک تم نواربندی ستون مشخص شده را به محدوده اعمال میکند. |
apply Column Banding(bandingTheme, showHeader, showFooter) | Banding | یک تم نواربندی ستون مشخص شده را به محدودهای با تنظیمات سربرگ و پاصفحه مشخص شده اعمال میکند. |
apply Row Banding() | Banding | یک تم نواربندی ردیف پیشفرض را به محدوده اعمال میکند. |
apply Row Banding(bandingTheme) | Banding | یک تم نواربندی ردیف مشخص شده را به محدوده اعمال میکند. |
apply Row Banding(bandingTheme, showHeader, showFooter) | Banding | یک تم نواربندی ردیف مشخص شده را به محدودهای با تنظیمات سربرگ و پاصفحه مشخص شده اعمال میکند. |
auto Fill(destination, series) | void | destination Range با دادههایی بر اساس دادههای موجود در این محدوده پر میکند. |
auto Fill To Neighbor(series) | void | محدودهای را برای پر کردن با دادههای جدید بر اساس سلولهای همسایه محاسبه میکند و به طور خودکار آن محدوده را با مقادیر جدید بر اساس دادههای موجود در این محدوده پر میکند. |
break Apart() | Range | سلولهای چند ستونی موجود در محدوده را دوباره به سلولهای مجزا تقسیم کنید. |
can Edit() | Boolean | تعیین میکند که آیا کاربر اجازه ویرایش تک تک سلولهای موجود در محدوده را دارد یا خیر. |
check() | Range | وضعیت کادرهای انتخاب در محدوده را به «علامتگذاریشده» تغییر میدهد. |
clear() | Range | طیف وسیعی از محتوا و قالبها را پاک میکند. |
clear(options) | Range | محدودهی محتوا، قالب، قوانین اعتبارسنجی دادهها و/یا نظرات را، همانطور که با گزینههای پیشرفتهی داده شده مشخص شده است، پاک میکند. |
clear Content() | Range | محتوای محدوده را پاک میکند، اما قالببندی آن دستنخورده باقی میماند. |
clear Data Validations() | Range | قوانین اعتبارسنجی دادهها را برای محدوده پاک میکند. |
clear Format() | Range | قالببندی این محدوده را پاک میکند. |
clear Note() | Range | یادداشت موجود در سلول یا سلولهای داده شده را پاک میکند. |
collapse Groups() | Range | تمام گروههایی را که کاملاً در محدوده قرار دارند، جمع میکند. |
copy Format To Range(gridId, column, columnEnd, row, rowEnd) | void | قالببندی محدوده را در محل داده شده کپی کنید. |
copy Format To Range(sheet, column, columnEnd, row, rowEnd) | void | قالببندی محدوده را در محل داده شده کپی کنید. |
copy To(destination) | void | دادهها را از طیف وسیعی از سلولها به طیف دیگری از سلولها کپی میکند. |
copy To(destination, copyPasteType, transposed) | void | دادهها را از طیف وسیعی از سلولها به طیف دیگری از سلولها کپی میکند. |
copy To(destination, options) | void | دادهها را از طیف وسیعی از سلولها به طیف دیگری از سلولها کپی میکند. |
copy Values To Range(gridId, column, columnEnd, row, rowEnd) | void | محتوای محدوده را در محل داده شده کپی کنید. |
copy Values To Range(sheet, column, columnEnd, row, rowEnd) | void | محتوای محدوده را در محل داده شده کپی کنید. |
create Data Source Pivot Table(dataSource) | Data Source Pivot Table | یک جدول محوری خالی از منبع داده از منبع داده ایجاد میکند که در اولین سلول در این محدوده قرار میگیرد. |
create Data Source Table(dataSource) | Data Source Table | یک جدول منبع داده خالی از منبع داده ایجاد میکند که در اولین سلول در این محدوده قرار میگیرد. |
create Developer Metadata Finder() | Developer Metadata Finder | یک DeveloperMetadataFinderApi برای یافتن متادیتای توسعهدهنده در محدودهی این محدوده برمیگرداند. |
create Filter() | Filter | یک فیلتر ایجاد میکند و آن را روی محدوده مشخص شده روی برگه اعمال میکند. |
create Pivot Table(sourceData) | Pivot Table | یک جدول محوری خالی از source Data مشخص شده ایجاد میکند که در اولین سلول در این محدوده قرار دارد. |
create Text Finder(findText) | Text Finder | یک یابنده متن برای محدوده ایجاد میکند که میتواند متن را در این محدوده پیدا و جایگزین کند. |
delete Cells(shiftDimension) | void | این محدوده از سلولها را حذف میکند. |
expand Groups() | Range | گروههای فروپاشیده شدهای را که محدوده یا ضامن کنترل آنها با این محدوده تلاقی میکند، گسترش میدهد. |
getA1Notation() | String | یک توصیف رشتهای از محدوده را با نمادگذاری A1 برمیگرداند. |
get Background() | String | رنگ پسزمینه سلول بالا سمت چپ در محدوده را برمیگرداند (برای مثال، '#ffffff' ). |
get Background Object() | Color | رنگ پسزمینه سلول بالا سمت چپ در محدوده را برمیگرداند. |
get Background Objects() | Color[][] | رنگهای پسزمینه سلولهای موجود در محدوده را برمیگرداند. |
get Backgrounds() | String[][] | رنگهای پسزمینه سلولهای موجود در محدوده را برمیگرداند (برای مثال، '#ffffff' ). |
get Bandings() | Banding[] | تمام نوارهایی را که برای هر سلول در این محدوده اعمال میشود، برمیگرداند. |
get Cell(row, column) | Range | یک سلول داده شده را در یک محدوده برمیگرداند. |
get Column() | Integer | موقعیت ستون شروع را برای این محدوده برمیگرداند. |
get Data Region() | Range | یک کپی از محدودهای که در چهار Direction اصلی گسترش یافته است را برمیگرداند تا تمام سلولهای مجاور دارای داده را پوشش دهد. |
get Data Region(dimension) | Range | اگر بُعد مشخص شده Dimension.ROWS باشد، یک کپی از محدودهی گسترشیافتهی Direction.UP و Direction.DOWN را برمیگرداند، یا اگر بُعد Dimension.COLUMNS باشد Direction.NEXT و Direction.PREVIOUS برمیگرداند. |
get Data Source Formula() | Data Source Formula |null | Data Source Formula برای اولین سلول در محدوده برمیگرداند، یا اگر سلول حاوی فرمول منبع داده نباشد، null برمیگرداند. |
get Data Source Formulas() | Data Source Formula[] | Data Source Formula Formulas) را برای سلولهای موجود در محدوده برمیگرداند. |
get Data Source Pivot Tables() | Data Source Pivot Table[] | تمام جداول محوری منبع داده که با محدوده تلاقی دارند را دریافت میکند. |
get Data Source Tables() | Data Source Table[] | تمام جداول منبع داده که با محدوده تلاقی دارند را دریافت میکند. |
get Data Source Url() | String | یک URL برای دادههای موجود در این محدوده برمیگرداند که میتواند برای ایجاد نمودارها و پرسوجوها استفاده شود. |
get Data Table() | Data Table | دادههای درون این شیء را به عنوان یک DataTable برگردانید. |
get Data Table(firstRowIsHeader) | Data Table | دادههای داخل این محدوده را به عنوان یک DataTable برگردانید. |
get Data Validation() | Data Validation | قانون اعتبارسنجی دادهها را برای سلول بالا سمت چپ در محدوده برمیگرداند. |
get Data Validations() | Data Validation[][] | قوانین اعتبارسنجی دادهها را برای همه سلولهای موجود در محدوده برمیگرداند. |
get Developer Metadata() | Developer Metadata[] | متادیتای توسعهدهندهی مرتبط با این محدوده را دریافت میکند. |
get Display Value() | String | مقدار نمایش داده شده سلول بالا سمت چپ در محدوده را برمیگرداند. |
get Display Values() | String[][] | شبکه مستطیلی مقادیر را برای این محدوده برمیگرداند. |
get Filter() | Filter |null | فیلتر روی شیتی که این محدوده به آن تعلق دارد را برمیگرداند، یا اگر فیلتری روی شیت وجود نداشته باشد null برمیگرداند. |
get Font Color Object() | Color | رنگ فونت سلول را در گوشه بالا سمت چپ محدوده برمیگرداند. |
get Font Color Objects() | Color[][] | رنگ فونت سلولهای موجود در محدوده را برمیگرداند. |
get Font Families() | String[][] | خانوادههای فونت سلولهای موجود در محدوده را برمیگرداند. |
get Font Family() | String | خانواده فونت سلول را در گوشه بالا سمت چپ محدوده برمیگرداند. |
get Font Line() | String | سبک خط سلول را در گوشه بالا سمت چپ محدوده ( 'underline' ، 'line-through' یا 'none' ) برمیگرداند. |
get Font Lines() | String[][] | سبک خط سلولهای موجود در محدوده ( 'underline' ، 'line-through' یا 'none' ) را برمیگرداند. |
get Font Size() | Integer | اندازه فونت را بر حسب نقطه (point size) برای سلول گوشه بالا سمت چپ محدوده برمیگرداند. |
get Font Sizes() | Integer[][] | اندازه فونت سلولهای موجود در محدوده را برمیگرداند. |
get Font Style() | String | سبک فونت ( 'italic' یا 'normal' ) سلول را در گوشه بالا سمت چپ محدوده برمیگرداند. |
get Font Styles() | String[][] | سبک فونت سلولهای موجود در محدوده را برمیگرداند. |
get Font Weight() | String | وزن فونت (عادی/جسورانه) سلول را در گوشه بالا سمت چپ محدوده برمیگرداند. |
get Font Weights() | String[][] | وزن فونت سلولهای موجود در محدوده را برمیگرداند. |
get Formula() | String | فرمول (نمادگذاری A1) را برای سلول بالا سمت چپ محدوده برمیگرداند، یا اگر سلول خالی باشد یا حاوی فرمول نباشد، یک رشته خالی برمیگرداند. |
get Formula R1C1() | String | فرمول (نماد R1C1) را برای یک سلول داده شده برمیگرداند، و در صورت عدم وجود null برمیگرداند. |
get Formulas() | String[][] | فرمولها (نمادگذاری A1) را برای سلولهای موجود در محدوده برمیگرداند. |
get Formulas R1C1() | String[][] | فرمولها (نماد R1C1) را برای سلولهای موجود در محدوده برمیگرداند. |
get Grid Id() | Integer | شناسه شبکه (grid ID) برگه والد محدوده را برمیگرداند. |
get Height() | Integer | ارتفاع محدوده را برمیگرداند. |
get Horizontal Alignment() | String | تراز افقی متن (چپ/وسط/راست) سلول را در گوشه بالا سمت چپ محدوده برمیگرداند. |
get Horizontal Alignments() | String[][] | ترازبندی افقی سلولهای موجود در محدوده را برمیگرداند. |
get Last Column() | Integer | موقعیت ستون انتهایی را برمیگرداند. |
get Last Row() | Integer | موقعیت ردیف انتهایی را برمیگرداند. |
get Merged Ranges() | Range[] | آرایهای از اشیاء Range را برمیگرداند که نشاندهنده سلولهای ادغامشدهای هستند که یا کاملاً در محدوده فعلی قرار دارند، یا حداقل حاوی یک سلول در محدوده فعلی هستند. |
get Next Data Cell(direction) | Range | با شروع از سلول در ستون و ردیف اول محدوده، سلول بعدی را در جهت داده شده که لبه یک محدوده پیوسته از سلولها با دادهها در آنها یا سلول در لبه صفحه گسترده در آن جهت است، برمیگرداند. |
get Note() | String | یادداشت مرتبط با محدوده داده شده را برمیگرداند. |
get Notes() | String[][] | یادداشتهای مرتبط با سلولهای موجود در محدوده را برمیگرداند. |
get Num Columns() | Integer | تعداد ستونهای موجود در این محدوده را برمیگرداند. |
get Num Rows() | Integer | تعداد ردیفهای موجود در این محدوده را برمیگرداند. |
get Number Format() | String | قالببندی عدد یا تاریخ سلول بالا سمت چپ محدوده داده شده را دریافت کنید. |
get Number Formats() | String[][] | فرمتهای عددی یا تاریخی را برای سلولهای موجود در محدوده برمیگرداند. |
get Rich Text Value() | Rich Text Value |null | مقدار Rich Text را برای سلول بالا سمت چپ محدوده برمیگرداند، یا اگر مقدار سلول متن نباشد، null برمیگرداند. |
get Rich Text Values() | Rich Text Value[][] | مقادیر متن غنی (Rich Text) را برای سلولهای موجود در محدوده برمیگرداند. |
get Row() | Integer | موقعیت ردیف را برای این محدوده برمیگرداند. |
get Row Index() | Integer | موقعیت ردیف را برای این محدوده برمیگرداند. |
get Sheet() | Sheet | شیتی که این محدوده به آن تعلق دارد را برمیگرداند. |
get Text Direction() | Text Direction | جهت متن را برای سلول بالا سمت چپ محدوده برمیگرداند. |
get Text Directions() | Text Direction[][] | جهت متن را برای سلولهای موجود در محدوده برمیگرداند. |
get Text Rotation() | Text Rotation | تنظیمات چرخش متن را برای سلول بالا سمت چپ محدوده برمیگرداند. |
get Text Rotations() | Text Rotation[][] | تنظیمات چرخش متن را برای سلولهای موجود در محدوده برمیگرداند. |
get Text Style() | Text Style | سبک متن را برای سلول بالا سمت چپ محدوده برمیگرداند. |
get Text Styles() | Text Style[][] | استایلهای متن را برای سلولهای موجود در محدوده برمیگرداند. |
get Value() | Object | مقدار سلول بالا سمت چپ در محدوده را برمیگرداند. |
get Values() | Object[][] | شبکه مستطیلی مقادیر را برای این محدوده برمیگرداند. |
get Vertical Alignment() | String | تراز عمودی (بالا/وسط/پایین) سلول را در گوشه بالا سمت چپ محدوده برمیگرداند. |
get Vertical Alignments() | String[][] | ترازبندی عمودی سلولهای موجود در محدوده را برمیگرداند. |
get Width() | Integer | عرض محدوده را بر حسب ستون برمیگرداند. |
get Wrap() | Boolean | برمیگرداند که آیا متن درون سلول جمع میشود یا خیر. |
get Wrap Strategies() | Wrap Strategy[][] | استراتژیهای بستهبندی متن را برای سلولهای موجود در محدوده برمیگرداند. |
get Wrap Strategy() | Wrap Strategy | استراتژی چیدمان متن را برای سلول بالا سمت چپ محدوده برمیگرداند. |
get Wraps() | Boolean[][] | برمیگرداند که آیا متن درون سلولها به صورت لایه لایه قرار میگیرد یا خیر. |
insert Cells(shiftDimension) | Range | سلولهای خالی را در این محدوده وارد میکند. |
insert Checkboxes() | Range | کادرهای انتخاب را در هر سلول در محدوده درج میکند، که با true برای علامتگذاری شده و false برای علامتگذاری نشده پیکربندی شده است. |
insert Checkboxes(checkedValue) | Range | کادرهای انتخاب را در هر سلول در محدوده وارد میکند، که با یک مقدار سفارشی برای علامتگذاری شده و یک رشته خالی برای علامتگذاری نشده پیکربندی شده است. |
insert Checkboxes(checkedValue, uncheckedValue) | Range | کادرهای انتخاب را در هر سلول در محدوده وارد میکند، که با مقادیر سفارشی برای حالتهای انتخابشده و انتخابنشده پیکربندی شدهاند. |
is Blank() | Boolean | اگر محدوده کاملاً خالی باشد، true را برمیگرداند. |
is Checked() | Boolean | برمیگرداند که آیا همه سلولهای موجود در محدوده، حالت چکباکس خود را «تیکدار» (checked) دارند یا خیر. |
is End Column Bounded() | Boolean | مشخص میکند که آیا انتهای محدوده به یک ستون خاص محدود شده است یا خیر. |
is End Row Bounded() | Boolean | تعیین میکند که آیا انتهای محدوده به یک ردیف خاص محدود شده است یا خیر. |
is Part Of Merge() | Boolean | اگر سلولهای موجود در محدودهی فعلی با سلولهای ادغامشده همپوشانی داشته باشند، مقدار true را برمیگرداند. |
is Start Column Bounded() | Boolean | تعیین میکند که آیا شروع محدوده به یک ستون خاص محدود شده است یا خیر. |
is Start Row Bounded() | Boolean | تعیین میکند که آیا شروع محدوده به یک ردیف خاص محدود شده است یا خیر. |
merge() | Range | سلولهای موجود در محدوده را با هم در یک بلوک واحد ادغام میکند. |
merge Across() | Range | سلولهای موجود در محدوده را در ستونهای آن محدوده ادغام کنید. |
merge Vertically() | Range | سلولهای موجود در محدوده را با هم ادغام میکند. |
move To(target) | void | از این محدوده، هم قالب و هم مقادیر را برش داده و به محدوده هدف بچسبانید (Cut and Paste). |
offset(rowOffset, columnOffset) | Range | یک محدوده جدید را برمیگرداند که به اندازه تعداد ردیفها و ستونهای داده شده (که میتواند منفی باشد) از این محدوده فاصله دارد. |
offset(rowOffset, columnOffset, numRows) | Range | یک محدوده جدید را برمیگرداند که نسبت به محدوده فعلی است، که نقطه بالا سمت چپ آن به اندازه ردیفها و ستونهای داده شده و با ارتفاع داده شده در سلولها، از محدوده فعلی فاصله دارد. |
offset(rowOffset, columnOffset, numRows, numColumns) | Range | یک محدوده جدید را برمیگرداند که نسبت به محدوده فعلی است، که نقطه بالا سمت چپ آن به اندازه ردیفها و ستونهای داده شده و با ارتفاع و عرض داده شده در سلولها، از محدوده فعلی فاصله دارد. |
protect() | Protection | شیءای ایجاد میکند که میتواند از ویرایش محدوده به جز توسط کاربرانی که مجوز دارند، جلوگیری کند. |
randomize() | Range | ترتیب ردیفها را در محدوده داده شده تصادفی میکند. |
remove Checkboxes() | Range | تمام کادرهای انتخاب را از محدوده حذف میکند. |
remove Duplicates() | Range | ردیفهایی را در این محدوده که حاوی مقادیری هستند که تکراری از مقادیر در هر ردیف قبلی هستند، حذف میکند. |
remove Duplicates(columnsToCompare) | Range | ردیفهایی را در این محدوده حذف میکند که حاوی مقادیری در ستونهای مشخصشده هستند که تکراری از مقادیر هر ردیف قبلی هستند. |
set Background(color) | Range | رنگ پسزمینه تمام سلولهای موجود در محدوده را با استفاده از نمادگذاری CSS (مانند '#ffffff' یا 'white' ) تنظیم میکند. |
set Background Object(color) | Range | رنگ پسزمینه تمام سلولهای موجود در محدوده را تنظیم میکند. |
set Background Objects(color) | Range | یک شبکه مستطیلی از رنگهای پسزمینه تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Background RGB(red, green, blue) | Range | با استفاده از مقادیر RGB (اعداد صحیح بین ۰ تا ۲۵۵) رنگ پسزمینه را به رنگ داده شده تنظیم میکند. |
set Backgrounds(color) | Range | یک شبکه مستطیلی از رنگهای پسزمینه تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Border(top, left, bottom, right, vertical, horizontal) | Range | ویژگی حاشیه را تنظیم میکند. |
set Border(top, left, bottom, right, vertical, horizontal, color, style) | Range | ویژگی حاشیه را با رنگ و/یا سبک تنظیم میکند. |
set Data Validation(rule) | Range | یک قانون اعتبارسنجی داده برای همه سلولهای موجود در محدوده تنظیم میکند. |
set Data Validations(rules) | Range | قوانین اعتبارسنجی دادهها را برای همه سلولهای موجود در محدوده تنظیم میکند. |
set Font Color(color) | Range | رنگ فونت را در نمادگذاری CSS تنظیم میکند (مانند '#ffffff' یا 'white' ). |
set Font Color Object(color) | Range | رنگ فونت محدوده داده شده را تنظیم میکند. |
set Font Color Objects(colors) | Range | یک شبکه مستطیلی از رنگهای فونت تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Font Colors(colors) | Range | یک شبکه مستطیلی از رنگهای فونت تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Font Families(fontFamilies) | Range | یک شبکه مستطیلی از خانوادههای فونت تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Font Family(fontFamily) | Range | خانواده فونت، مانند "Arial" یا "Helvetica" را تنظیم میکند. |
set Font Line(fontLine) | Range | سبک خط فونت محدوده داده شده ( 'underline' ، 'line-through' یا 'none' ) را تنظیم میکند. |
set Font Lines(fontLines) | Range | یک شبکه مستطیلی از سبکهای خط تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Font Size(size) | Range | اندازه فونت را تنظیم میکند، که منظور از size، اندازه نقطه مورد استفاده است. |
set Font Sizes(sizes) | Range | یک شبکه مستطیلی از اندازه فونتها تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Font Style(fontStyle) | Range | سبک فونت را برای محدوده داده شده ( 'italic' یا 'normal' ) تنظیم کنید. |
set Font Styles(fontStyles) | Range | یک شبکه مستطیلی از سبکهای فونت تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Font Weight(fontWeight) | Range | ضخامت فونت را برای محدوده داده شده (معمولی/جسورانه) تنظیم کنید. |
set Font Weights(fontWeights) | Range | یک شبکه مستطیلی از وزن فونتها تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Formula(formula) | Range | فرمول این محدوده را بهروزرسانی میکند. |
set Formula R1C1(formula) | Range | فرمول این محدوده را بهروزرسانی میکند. |
set Formulas(formulas) | Range | یک شبکه مستطیلی از فرمولها تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Formulas R1C1(formulas) | Range | یک شبکه مستطیلی از فرمولها تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Horizontal Alignment(alignment) | Range | تراز افقی (چپ به راست) را برای محدوده داده شده (چپ/مرکز/راست) تنظیم کنید. |
set Horizontal Alignments(alignments) | Range | یک شبکه مستطیلی از ترازهای افقی تنظیم میکند. |
set Note(note) | Range | یادداشت را روی مقدار داده شده تنظیم میکند. |
set Notes(notes) | Range | یک شبکه مستطیلی از یادداشتها تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Number Format(numberFormat) | Range | قالب عدد یا تاریخ را روی رشته قالببندی داده شده تنظیم میکند. |
set Number Formats(numberFormats) | Range | یک شبکه مستطیلی از قالبهای عدد یا تاریخ تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Rich Text Value(value) | Range | مقدار Rich Text را برای سلولهای موجود در محدوده تنظیم میکند. |
set Rich Text Values(values) | Range | یک شبکه مستطیلی از مقادیر Rich Text تنظیم میکند. |
set Show Hyperlink(showHyperlink) | Range | تعیین میکند که آیا محدوده باید هایپرلینکها را نشان دهد یا خیر. |
set Text Direction(direction) | Range | جهت متن را برای سلولهای موجود در محدوده تنظیم میکند. |
set Text Directions(directions) | Range | یک شبکه مستطیلی از جهتهای متن تنظیم میکند. |
set Text Rotation(degrees) | Range | تنظیمات چرخش متن را برای سلولهای موجود در محدوده تنظیم میکند. |
set Text Rotation(rotation) | Range | تنظیمات چرخش متن را برای سلولهای موجود در محدوده تنظیم میکند. |
set Text Rotations(rotations) | Range | یک شبکه مستطیلی از چرخشهای متن تنظیم میکند. |
set Text Style(style) | Range | سبک متن را برای سلولهای موجود در محدوده تنظیم میکند. |
set Text Styles(styles) | Range | یک شبکه مستطیلی از سبکهای متن تنظیم میکند. |
set Value(value) | Range | مقدار محدوده را تنظیم میکند. |
set Values(values) | Range | یک شبکه مستطیلی از مقادیر را تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Vertical Alignment(alignment) | Range | تراز عمودی (از بالا به پایین) را برای محدوده داده شده (بالا/وسط/پایین) تنظیم کنید. |
set Vertical Alignments(alignments) | Range | یک شبکه مستطیلی از ترازهای عمودی تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
set Vertical Text(isVertical) | Range | تنظیم میکند که آیا متن سلولهای موجود در محدوده روی هم قرار گیرد یا خیر. |
set Wrap(isWrapEnabled) | Range | پوشش سلولی محدوده داده شده را تنظیم کنید. |
set Wrap Strategies(strategies) | Range | یک شبکه مستطیلی از استراتژیهای پوشش (wrapping) تنظیم میکند. |
set Wrap Strategy(strategy) | Range | استراتژی چیدمان متن را برای سلولهای موجود در محدوده تنظیم میکند. |
set Wraps(isWrapEnabled) | Range | یک شبکه مستطیلی از سیاستهای بستهبندی کلمات تنظیم میکند (باید با ابعاد این محدوده مطابقت داشته باشد). |
shift Column Group Depth(delta) | Range | عمق گروهبندی ستونهای محدوده را به میزان مشخصشده تغییر میدهد. |
shift Row Group Depth(delta) | Range | عمق گروهبندی ردیفهای محدوده را به میزان مشخصشده تغییر میدهد. |
sort(sortSpecObj) | Range | سلولها را در محدوده داده شده، بر اساس ستون و ترتیب مشخص شده، مرتب میکند. |
split Text To Columns() | void | یک ستون متن را بر اساس یک جداکننده خودکار، به چندین ستون تقسیم میکند. |
split Text To Columns(delimiter) | void | یک ستون متن را با استفاده از رشته مشخص شده به عنوان جداکننده سفارشی، به چندین ستون تقسیم میکند. |
split Text To Columns(delimiter) | void | یک ستون متن را بر اساس جداکننده مشخص شده، به چندین ستون تقسیم میکند. |
trim Whitespace() | Range | فضای خالی (مانند فاصله، تب یا خط جدید) را در هر سلول در این محدوده حذف میکند. |
uncheck() | Range | وضعیت کادرهای انتخاب در محدوده را به «بدون علامت» تغییر میدهد. |
مستندات دقیق
activate()
محدوده مشخص شده را به عنوان active range ، با سلول بالا سمت چپ در محدوده به عنوان current cell ، تنظیم میکند.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getRange('A1:D10'); range.activate(); const selection = sheet.getSelection(); // Current cell: A1 const currentCell = selection.getCurrentCell(); // Active Range: A1:D10 const activeRange = selection.getActiveRange();
بازگشت
Range — این محدوده، برای زنجیرهسازی.
activate As Current Cell()
سلول مشخص شده را به عنوان current cell تنظیم میکند.
اگر سلول مشخص شده در یک محدوده موجود وجود داشته باشد، آن محدوده به محدوده فعال تبدیل میشود و آن سلول، سلول فعلی خواهد بود.
اگر سلول مشخص شده در هیچ محدودهی موجودی وجود نداشته باشد، انتخاب موجود حذف شده و سلول مورد نظر به عنوان سلول فعلی و محدودهی فعال در نظر گرفته میشود.
توجه: Range مشخص شده باید شامل یک سلول باشد، در غیر این صورت یک استثنا ایجاد میکند.
// Gets the first sheet of the spreadsheet. const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; // Gets the cell B5 and sets it as the active cell. const range = sheet.getRange('B5'); const currentCell = range.activateAsCurrentCell(); // Logs the activated cell. console.log(currentCell.getA1Notation());
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
add Developer Metadata(key)
متادیتای توسعهدهنده را با کلید مشخصشده به محدوده اضافه میکند.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 on the sheet. const range = sheet.getRange('2:2'); // Adds the key 'NAME' to the developer metadata for row 2. range.addDeveloperMetadata('NAME'); // Gets the metadata and logs it to the console. const developerMetaData = range.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey());
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
key | String | کلید فراداده جدید توسعهدهنده. |
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
add Developer Metadata(key, visibility)
فرادادههای توسعهدهنده را با کلید و قابلیت مشاهده مشخصشده به محدوده اضافه میکند.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 on Sheet1. const range = sheet.getRange('2:2'); // Adds the key 'NAME' and sets the developer metadata visibility to 'DOCUMENT' // for row 2 on Sheet1. range.addDeveloperMetadata( 'NAME', SpreadsheetApp.DeveloperMetadataVisibility.DOCUMENT, ); // Gets the updated metadata info and logs it to the console. const developerMetaData = range.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey()); console.log(developerMetaData.getVisibility().toString());
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
key | String | کلید فراداده جدید توسعهدهنده. |
visibility | Developer Metadata Visibility | قابلیت مشاهدهی ابردادهی جدید توسعهدهنده. |
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
add Developer Metadata(key, value)
متادیتای توسعهدهنده را با کلید و مقدار مشخصشده به محدوده اضافه میکند.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 of Sheet1. const range = sheet.getRange('2:2'); // Adds the key 'NAME' and sets the value to 'GOOGLE' for the metadata of row 2. range.addDeveloperMetadata('NAME', 'GOOGLE'); // Gets the metadata and logs it to the console. const developerMetaData = range.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey()); console.log(developerMetaData.getValue());
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
key | String | کلید فراداده جدید توسعهدهنده. |
value | String | مقدار برای ابرداده توسعهدهنده جدید. |
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
add Developer Metadata(key, value, visibility)
فرادادههای توسعهدهنده را با کلید، مقدار و قابلیت مشاهدهی مشخصشده به محدوده اضافه میکند.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 on the sheet. const range = sheet.getRange('2:2'); // Adds the key 'NAME', sets the value to 'GOOGLE', and sets the visibility // to PROJECT for row 2 on the sheet. range.addDeveloperMetadata( 'NAME', 'GOOGLE', SpreadsheetApp.DeveloperMetadataVisibility.PROJECT, ); // Gets the updated metadata info and logs it to the console. const developerMetaData = range.getDeveloperMetadata()[0]; console.log(developerMetaData.getKey()); console.log(developerMetaData.getValue()); console.log(developerMetaData.getVisibility().toString());
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
key | String | کلید فراداده جدید توسعهدهنده. |
value | String | مقدار برای ابرداده توسعهدهنده جدید. |
visibility | Developer Metadata Visibility | قابلیت مشاهدهی ابردادهی جدید توسعهدهنده. |
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
apply Column Banding()
یک تم نواربندی ستون پیشفرض را به محدوده اعمال میکند. به طور پیشفرض، نواربندی دارای رنگ سربرگ و بدون رنگ پاصفحه است.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 on the sheet. const range = sheet.getRange('2:2'); // Applies column banding to row 2. const colBanding = range.applyColumnBanding(); // Gets the first banding on the sheet and logs the color of the header column. console.log( sheet.getBandings()[0] .getHeaderColumnColorObject() .asRgbColor() .asHexString(), ); // Gets the first banding on the sheet and logs the color of the second column. console.log( sheet.getBandings()[0] .getSecondColumnColorObject() .asRgbColor() .asHexString(), );
بازگشت
Banding - باندینگ جدید.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
apply Column Banding(bandingTheme)
یک تم نواربندی ستون مشخص شده را به محدوده اعمال میکند. به طور پیشفرض، نواربندی دارای رنگ سربرگ و بدون رنگ پاصفحه است.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 on the sheet. const range = sheet.getRange('2:2'); // Applies the INDIGO color banding theme to the columns in row 2. const colBanding = range.applyColumnBanding(SpreadsheetApp.BandingTheme.INDIGO); // Gets the first banding on the sheet and logs the color of the second column. console.log( sheet.getBandings()[0] .getSecondColumnColorObject() .asRgbColor() .asHexString(), );
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
banding Theme | Banding Theme | یک تم رنگی برای اعمال روی ستونهای موجود در محدوده. |
بازگشت
Banding - باندینگ جدید.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
apply Column Banding(bandingTheme, showHeader, showFooter)
یک تم نواربندی ستون مشخص شده را به محدودهای با تنظیمات سربرگ و پاصفحه مشخص شده اعمال میکند.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets rows 12-22 on the sheet. const range = sheet.getRange('12:22'); // Applies the BLUE color banding theme to rows 12-22. // Sets the header visibility to false and the footer visibility to true. const colBanding = range.applyColumnBanding( SpreadsheetApp.BandingTheme.BLUE, false, true, ); // Gets the banding color and logs it to the console. console.log( sheet.getBandings()[0] .getSecondColumnColorObject() .asRgbColor() .asHexString(), ); // Gets the header color object and logs it to the console. Returns null because // the header visibility is set to false. console.log(sheet.getBandings()[0].getHeaderColumnColorObject()); // Gets the footer color and logs it to the console. console.log( sheet.getBandings()[0] .getFooterColumnColorObject() .asRgbColor() .asHexString(), );
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
banding Theme | Banding Theme | یک تم رنگی برای اعمال روی ستونهای موجود در محدوده. |
show Header | Boolean | اگر true ، رنگ هدر تم نواربندی روی ستون اول اعمال میشود. |
show Footer | Boolean | اگر true ، رنگ پاورقیِ تمِ بندی به آخرین ستون اعمال میشود. |
بازگشت
Banding - باندینگ جدید.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
apply Row Banding()
یک تم نواربندی ردیف پیشفرض را به محدوده اعمال میکند. به طور پیشفرض، نواربندی دارای رنگ سربرگ و بدون رنگ پاصفحه است.
// Opens the spreadsheet by its URL. If you created your script from within a // Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets rows 1-30 on Sheet1. const range = sheet.getRange('1:30'); // Applies row banding to rows 1-30. range.applyRowBanding(); // Gets the hex color of the second banded row. const secondRowColor = range.getBandings()[0].getSecondRowColorObject().asRgbColor().asHexString(); // Logs the hex color to console. console.log(secondRowColor);
بازگشت
Banding - باندینگ.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
apply Row Banding(bandingTheme)
یک تم نواربندی ردیف مشخص شده را به محدوده اعمال میکند. به طور پیشفرض، نواربندی دارای رنگ سربرگ و بدون رنگ پاصفحه است.
// Opens the spreadsheet by its URL. If you created your script from within a // Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets rows 1-30 on Sheet1. const range = sheet.getRange('1:30'); // Applies the INDIGO row banding theme to rows 1-30. range.applyRowBanding(SpreadsheetApp.BandingTheme.INDIGO); // Gets the hex color of the second banded row. const secondRowColor = range.getBandings()[0].getSecondRowColorObject().asRgbColor().asHexString(); // Logs the hex color to console. console.log(secondRowColor);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
banding Theme | Banding Theme | یک تم رنگی برای اعمال روی ردیفهای موجود در محدوده. |
بازگشت
Banding - باندینگ جدید.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
apply Row Banding(bandingTheme, showHeader, showFooter)
یک تم نواربندی ردیف مشخص شده را به محدودهای با تنظیمات سربرگ و پاصفحه مشخص شده اعمال میکند.
// Opens the spreadsheet by its URL. If you created your script from within a // Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets rows 1-30 on Sheet1. const range = sheet.getRange('1:30'); // Applies the INDIGO row banding to rows 1-30 and // specifies to hide the header and show the footer. range.applyRowBanding(SpreadsheetApp.BandingTheme.INDIGO, false, true);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
banding Theme | Banding Theme | یک تم رنگی برای اعمال روی ردیفهای موجود در محدوده. |
show Header | Boolean | اگر true ، رنگ هدر تم نواربندی روی ردیف اول اعمال میشود. |
show Footer | Boolean | اگر true ، رنگ پاورقیِ تمِ بندی به آخرین ردیف اعمال میشود. |
بازگشت
Banding - باندینگ جدید.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
auto Fill(destination, series)
destination Range با دادههایی بر اساس دادههای موجود در این محدوده پر میکند. مقادیر جدید نیز توسط نوع series مشخص شده تعیین میشوند. محدوده مقصد باید شامل این محدوده باشد و آن را فقط در یک جهت گسترش دهد. به عنوان مثال، دستور زیر A1:A20 را با یک سری اعداد افزایشی بر اساس مقادیر فعلی در A1:A4 پر میکند:
const sheet = SpreadsheetApp.getActiveSheet(); // Has values [1, 2, 3, 4]. const sourceRange = sheet.getRange('A1:A4'); // The range to fill with values. const destination = sheet.getRange('A1:A20'); // Inserts new values in A5:A20, continuing the pattern expressed in A1:A4 sourceRange.autoFill(destination, SpreadsheetApp.AutoFillSeries.DEFAULT_SERIES);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
destination | Range | محدودهای که قرار است به صورت خودکار با مقادیر پر شود. محدوده مقصد باید شامل این محدوده باشد و آن را فقط در یک جهت (به سمت بالا، پایین، چپ یا راست) گسترش دهد. |
series | Auto Fill Series | نوع سری autoFill که باید برای محاسبه مقادیر جدید استفاده شود. تأثیر این سری بر اساس نوع و میزان دادههای منبع متفاوت است. |
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
auto Fill To Neighbor(series)
محدودهای را برای پر کردن با دادههای جدید بر اساس سلولهای همسایه محاسبه میکند و به طور خودکار آن محدوده را با مقادیر جدید بر اساس دادههای موجود در این محدوده پر میکند. این مقادیر جدید نیز توسط نوع series مشخص شده تعیین میشوند.
محدوده مقصد محاسبهشده، دادههای اطراف را برای تعیین محل درج مقادیر جدید در نظر میگیرد: اگر دادههایی در سمت چپ یا راست ستونی که به صورت خودکار پر میشود، وجود داشته باشد، مقادیر جدید فقط تا محدوده این دادههای مجاور امتداد مییابند.
برای مثال، اگر A1:A20 با مجموعهای از اعداد صعودی پر شده باشد و این متد روی محدوده B1:B4 که شامل مجموعهای از تاریخها است فراخوانی شود، مقادیر جدید فقط در B5:B20 وارد میشوند. به این ترتیب، این مقادیر جدید به سلولهایی که حاوی مقادیر ستون A هستند، "میچسبند".
const sheet = SpreadsheetApp.getActiveSheet(); // A1:A20 has values [1, 2, 3, ... 20]. // B1:B4 has values [1/1/2017, 1/2/2017, ...] const sourceRange = sheet.getRange('B1:B4'); // Results in B5:B20 having values [1/5/2017, ... 1/20/2017] sourceRange.autoFillToNeighbor(SpreadsheetApp.AutoFillSeries.DEFAULT_SERIES);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
series | Auto Fill Series | نوع سری autoFill که باید برای محاسبه مقادیر جدید استفاده شود. تأثیر این سری بر اساس نوع و میزان دادههای منبع متفاوت است. |
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
break Apart()
سلولهای چند ستونی موجود در محدوده را دوباره به سلولهای مجزا تقسیم کنید.
فراخوانی این تابع روی یک محدوده معادل انتخاب یک محدوده و کلیک روی Format > Merge cells > Unmerge است .
// Opens the spreadsheet by its URL. If you created your script from within a // Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:C6 on Sheet1. const range = sheet.getRange('A1:C6'); // Unmerges the range A1:C6 into individual cells. range.breakApart();
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
can Edit()
تعیین میکند که آیا کاربر اجازه ویرایش هر سلول در محدوده را دارد یا خیر. مالک صفحه گسترده همیشه قادر به ویرایش محدودهها و برگههای محافظتشده است.
// Opens the spreadsheet by its URL. If you created your script from within a // Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:C6 on Sheet1. const range = sheet.getRange('A1:C6'); // Logs whether the user has permission to edit every cell in the range. console.log(range.canEdit());
بازگشت
Boolean - اگر کاربر اجازه ویرایش تک تک سلولهای محدوده را داشته باشد، true و در غیر این صورت false برمیگرداند.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
check()
وضعیت کادرهای انتخاب در محدوده را به «علامتگذاریشده» تغییر میدهد. سلولهایی از محدوده را که در حال حاضر حاوی مقدار پیکربندیشدهی علامتگذاریشده یا علامتگذارینشده نیستند، نادیده میگیرد.
// Changes the state of cells which currently contain either the checked or // unchecked value configured in the range A1:B10 to 'checked'. const range = SpreadsheetApp.getActive().getRange('A1:B10'); range.check();
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear()
طیف وسیعی از محتوا و قالبها را پاک میکند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:D10'); range.clear();
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear(options)
محدوده محتوا، قالب، قوانین اعتبارسنجی دادهها و/یا نظرات را، همانطور که با گزینههای پیشرفته داده شده مشخص شده است، پاک میکند. به طور پیشفرض همه دادهها پاک میشوند.
// The code below clears range C2:G7 in the active sheet, but preserves the // format, data validation rules, and comments. SpreadsheetApp.getActiveSheet().getRange(2, 3, 6, 5).clear({ contentsOnly: true });
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
options | Object | یک شیء جاوا اسکریپت که پارامترهای پیشرفتهای را مطابق لیست زیر مشخص میکند. |
پارامترهای پیشرفته
| نام | نوع | توضیحات |
|---|---|---|
comments Only | Boolean | آیا فقط نظرات پاک شوند؟ |
contents Only | Boolean | اینکه آیا فقط محتویات پاک شود یا خیر. |
format Only | Boolean | آیا فقط قالب را پاک کنیم؛ توجه داشته باشید که پاک کردن قالب، قوانین اعتبارسنجی دادهها را نیز پاک میکند. |
validations Only | Boolean | آیا فقط قوانین اعتبارسنجی دادهها پاک شوند؟ |
skip Filtered Rows | Boolean | آیا از پاک کردن ردیفهای فیلتر شده جلوگیری شود؟ |
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear Content()
محتوای محدوده را پاک میکند، اما قالببندی آن دستنخورده باقی میماند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:D10'); range.clearContent();
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear Data Validations()
قوانین اعتبارسنجی دادهها را برای محدوده پاک میکند.
// Clear the data validation rules for cells A1:B5. const range = SpreadsheetApp.getActive().getRange('A1:B5'); range.clearDataValidations();
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear Format()
قالببندی این محدوده را پاک میکند.
این کار قالببندی متن را برای سلول یا سلولهای موجود در محدوده پاک میکند، اما هیچ یک از قوانین قالببندی اعداد را بازنشانی نمیکند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:D10'); range.clearFormat();
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
clear Note()
یادداشت موجود در سلول یا سلولهای داده شده را پاک میکند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:D10'); range.clearNote();
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
collapse Groups()
تمام گروههایی را که بهطور کامل در محدوده قرار دارند، از هم جدا میکند. اگر هیچ گروهی بهطور کامل در محدوده نباشد، عمیقترین گروه گسترشیافته که تا حدی در محدوده قرار دارد، از هم جدا میشود.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getActiveRange(); // All row and column groups within the range are collapsed. range.collapseGroups();
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
copy Format To Range(gridId, column, columnEnd, row, rowEnd)
قالببندی محدوده را در مکان داده شده کپی میکند. اگر مقصد بزرگتر یا کوچکتر از محدوده منبع باشد، منبع بر اساس آن تکرار یا کوتاه میشود. توجه داشته باشید که این روش فقط قالببندی را کپی میکند.
برای توضیحات بیشتر در مورد پارامتر gridId، به get Grid Id() مراجعه کنید.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const source = ss.getSheets()[0]; const range = source.getRange('B2:D4'); // This copies the formatting in B2:D4 in the source sheet to // D4:F6 in the sheet with gridId 1555299895. Note that you can get the gridId // of a sheet by calling sheet.getSheetId() or range.getGridId(). range.copyFormatToRange(1555299895, 4, 6, 4, 6);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
grid Id | Integer | شناسه منحصر به فرد برگه در صفحه گسترده، صرف نظر از موقعیت آن. |
column | Integer | ستون اول محدوده هدف. |
column End | Integer | ستون انتهایی محدوده هدف. |
row | Integer | ردیف شروع محدوده هدف. |
row End | Integer | ردیف انتهایی محدوده هدف. |
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
همچنین ببینید
copy Format To Range(sheet, column, columnEnd, row, rowEnd)
قالببندی محدوده را در مکان داده شده کپی میکند. اگر مقصد بزرگتر یا کوچکتر از محدوده منبع باشد، منبع بر اساس آن تکرار یا کوتاه میشود. توجه داشته باشید که این روش فقط قالببندی را کپی میکند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const source = ss.getSheets()[0]; const destination = ss.getSheets()[1]; const range = source.getRange('B2:D4'); // This copies the formatting in B2:D4 in the source sheet to // D4:F6 in the second sheet range.copyFormatToRange(destination, 4, 6, 4, 6);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
sheet | Sheet | برگه هدف. |
column | Integer | ستون اول محدوده هدف. |
column End | Integer | ستون انتهایی محدوده هدف. |
row | Integer | ردیف شروع محدوده هدف. |
row End | Integer | ردیف انتهایی محدوده هدف. |
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
copy To(destination)
دادهها را از طیف وسیعی از سلولها به طیف وسیعی از سلولهای دیگر کپی میکند. هم مقادیر و هم قالببندی کپی میشوند.
// The code below copies the first 5 columns over to the 6th column. const sheet = SpreadsheetApp.getActiveSheet(); const rangeToCopy = sheet.getRange(1, 1, sheet.getMaxRows(), 5); rangeToCopy.copyTo(sheet.getRange(1, 6));
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
destination | Range | محدوده مقصد برای کپی کردن؛ فقط موقعیت سلول بالا سمت چپ مرتبط است. |
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
copy To(destination, copyPasteType, transposed)
دادهها را از طیف وسیعی از سلولها به طیف دیگری از سلولها کپی میکند.
// The code below copies only the values of the first 5 columns over to the 6th // column. const sheet = SpreadsheetApp.getActiveSheet(); sheet.getRange('A:E').copyTo( sheet.getRange('F1'), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false, );
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
destination | Range | محدوده مقصد برای کپی کردن؛ فقط موقعیت سلول بالا سمت چپ مرتبط است. |
copy Paste Type | Copy Paste Type | نوعی که نحوهی چسباندن محتویات محدوده به مقصد را مشخص میکند. |
transposed | Boolean | اینکه آیا محدوده باید در جهت جابجایی خود جایگذاری شود یا خیر. |
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
copy To(destination, options)
دادهها را از طیف وسیعی از سلولها به طیف وسیعی از سلولهای دیگر کپی میکند. به طور پیشفرض، هم مقادیر و هم قالببندی کپی میشوند، اما میتوان با استفاده از آرگومانهای پیشرفته، این مورد را لغو کرد.
// The code below copies only the values of the first 5 columns over to the 6th // column. const sheet = SpreadsheetApp.getActiveSheet(); sheet.getRange('A:E').copyTo(sheet.getRange('F1'), {contentsOnly: true});
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
destination | Range | محدوده مقصد برای کپی کردن؛ فقط موقعیت سلول بالا سمت چپ مرتبط است. |
options | Object | یک شیء جاوا اسکریپت که پارامترهای پیشرفتهای را مطابق لیست زیر مشخص میکند. |
پارامترهای پیشرفته
| نام | نوع | توضیحات |
|---|---|---|
format Only | Boolean | مشخص میکند که فقط فرمت باید کپی شود |
contents Only | Boolean | مشخص میکند که فقط محتوا باید کپی شود |
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
copy Values To Range(gridId, column, columnEnd, row, rowEnd)
محتوای محدوده را در مکان داده شده کپی میکند. اگر مقصد بزرگتر یا کوچکتر از محدوده منبع باشد، منبع به ترتیب تکرار یا کوتاه میشود.
برای توضیحات بیشتر در مورد پارامتر gridId، به get Grid Id() مراجعه کنید.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const source = ss.getSheets()[0]; const range = source.getRange('B2:D4'); // This copies the data in B2:D4 in the source sheet to // D4:F6 in the sheet with gridId 0 range.copyValuesToRange(0, 4, 6, 4, 6);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
grid Id | Integer | شناسه منحصر به فرد برگه در صفحه گسترده، صرف نظر از موقعیت آن. |
column | Integer | ستون اول محدوده هدف. |
column End | Integer | ستون انتهایی محدوده هدف. |
row | Integer | ردیف شروع محدوده هدف. |
row End | Integer | ردیف انتهایی محدوده هدف. |
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
همچنین ببینید
copy Values To Range(sheet, column, columnEnd, row, rowEnd)
محتوای محدوده را در مکان داده شده کپی میکند. اگر مقصد بزرگتر یا کوچکتر از محدوده منبع باشد، منبع به ترتیب تکرار یا کوتاه میشود.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const source = ss.getSheets()[0]; const destination = ss.getSheets()[1]; const range = source.getRange('B2:D4'); // This copies the data in B2:D4 in the source sheet to // D4:F6 in the second sheet range.copyValuesToRange(destination, 4, 6, 4, 6);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
sheet | Sheet | برگه هدف. |
column | Integer | ستون اول محدوده هدف. |
column End | Integer | ستون انتهایی محدوده هدف. |
row | Integer | ردیف شروع محدوده هدف. |
row End | Integer | ردیف انتهایی محدوده هدف. |
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
create Data Source Pivot Table(dataSource)
یک جدول محوری خالی از منبع داده از منبع داده ایجاد میکند که در اولین سلول در این محدوده قرار میگیرد.
این مثال نحوه ایجاد و پیکربندی یک جدول محوری منبع داده جدید را نشان میدهد.
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); const anchorCell = spreadsheet.getSheets()[0].getRange('A1'); const dataSource = spreadsheet.getDataSources()[0]; const pivotTable = anchorCell.createDataSourcePivotTable(dataSource); pivotTable.addRowGroup('dataColumnA'); pivotTable.addColumnGroup('dataColumnB'); pivotTable.addPivotValue( 'dataColumnC', SpreadsheetApp.PivotTableSummarizeFunction.SUM, ); pivotTable.addFilter( 'dataColumnA', SpreadsheetApp.newFilterCriteria().whenTextStartsWith('A').build(), );
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
data Source | Data Source | منبع دادهای که قرار است جدول محوری از آن ایجاد شود. |
بازگشت
Data Source Pivot Table — جدول محوری منبع داده که به تازگی ایجاد شده است.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
create Data Source Table(dataSource)
یک جدول منبع داده خالی از منبع داده ایجاد میکند که در اولین سلول در این محدوده قرار میگیرد.
این مثال نحوه ایجاد و پیکربندی یک جدول منبع داده جدید را نشان میدهد.
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); const anchorCell = spreadsheet.getSheets()[0].getRange('A1'); const dataSource = spreadsheet.getDataSources()[0]; const dataSourceTable = anchorCell.createDataSourceTable(dataSource) .addColumns('dataColumnA', 'dataColumnB', 'dataColumnC') .addSortSpec('dataColumnA', true) // ascending=true .addSortSpec('dataColumnB', false); // ascending=false
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
data Source | Data Source | منبع دادهای که قرار است جدول محوری از آن ایجاد شود. |
بازگشت
Data Source Table — جدول منبع داده تازه ایجاد شده.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
create Developer Metadata Finder()
یک DeveloperMetadataFinderApi را برای یافتن فرادادههای توسعهدهنده در محدوده این محدوده برمیگرداند. فرادادهها فقط در صورتی در محدوده محدوده قرار میگیرند که کاملاً در آن محدوده قرار داشته باشند. برای مثال، فرادادههای مرتبط با ردیف '3:3' در محدوده محدوده 'A1:D5' نیستند اما در محدوده محدوده '1:5' قرار دارند.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:C6. const range = sheet.getRange('A1:C6'); // Creates a developer metadata finder to search for metadata in the scope of // this range. const developerMetaDataFinder = range.createDeveloperMetadataFinder(); // Logs information about the developer metadata finder to the console. const developerMetaData = developerMetaDataFinder.find()[0]; console.log(developerMetaData.getKey()); console.log(developerMetaData.getValue()); console.log(developerMetaData.getVisibility().toString());
بازگشت
Developer Metadata Finder — یابندهی فرادادهی توسعهدهندگان برای جستجوی فراداده در محدودهی این محدوده.
create Filter()
یک فیلتر ایجاد میکند و آن را در محدوده مشخص شده در برگه اعمال میکند. شما نمیتوانید بیش از یک فیلتر در یک برگه ایجاد کنید. برای دسترسی و تغییر فیلتر خود پس از ایجاد، get Filter() یا Sheet.getFilter() استفاده کنید.
const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); // Creates a new filter and applies it to the range A1:C20 on the active sheet. function createFilter() { range.createFilter(); } // Gets the filter and applies criteria that only shows cells that aren't empty. function getFilterAddCriteria() { const filter = range.getFilter(); const criteria = SpreadsheetApp.newFilterCriteria().whenCellNotEmpty().build(); filter.setColumnFilterCriteria(2, criteria); }
Grid ، نوع پیشفرض صفحات، استفاده کنید. صفحات Grid، صفحاتی هستند که به پایگاه داده متصل نیستند. برای ایجاد انواع دیگر فیلترها، به موارد زیر مراجعه کنید:- یک فیلتر جدول محوری با
Pivot Table.addFilter(sourceDataColumn, filterCriteria)ایجاد کنید. - یک فیلتر برای یک شیت متصل به پایگاه داده با استفاده از
Data Source Sheet.addFilter(columnName, filterCriteria)ایجاد کنید. - یک فیلتر برای جدول محوری متصل به پایگاه داده با استفاده از
Data Source Pivot Table.addFilter(columnName, filterCriteria)ایجاد کنید.
بازگشت
Filter - فیلتر جدید.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
create Pivot Table(sourceData)
یک جدول محوری خالی از source Data مشخص شده ایجاد میکند که در اولین سلول در این محدوده قرار دارد.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets cell A1 as a range in order to place the pivot table. const range = sheet.getRange('A1'); // Gets the range of the source data for the pivot table. const dataRange = sheet.getRange('E12:G20'); // Creates an empty pivot table from the specified source data. const pivotTable = range.createPivotTable(dataRange); // Logs the values from the pivot table's source data to the console. console.log(pivotTable.getSourceDataRange().getValues());
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
source Data | Range | دادههایی که قرار است جدول محوری از آنها ایجاد شود. |
بازگشت
Pivot Table — Pivot Table تازه ایجاد شده.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
create Text Finder(findText)
یک یابنده متن برای محدوده ایجاد میکند که میتواند متن را در این محدوده پیدا و جایگزین کند.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getActiveRange(); // Creates a text finder for the range. const textFinder = range.createTextFinder('dog'); // Returns the first occurrence of 'dog'. const firstOccurrence = textFinder.findNext(); // Replaces the last found occurrence of 'dog' with 'cat' and returns the number // of occurrences replaced. const numOccurrencesReplaced = textFinder.replaceWith('cat');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
find Text | String | متنی که باید جستجو شود. |
بازگشت
Text Finder - Text Finder برای محدوده
delete Cells(shiftDimension)
این محدوده از سلولها را حذف میکند. دادههای موجود در برگه در امتداد بُعد ارائه شده به سمت محدوده حذف شده جابجا میشوند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:D10'); range.deleteCells(SpreadsheetApp.Dimension.COLUMNS);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
shift Dimension | Dimension | بُعدی که دادههای موجود در امتداد آن جابجا میشوند. |
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
expand Groups()
گروههای بستهشدهای را که محدوده یا ضامن کنترل آنها با این محدوده تلاقی میکند، گسترش میدهد. مکان ضامن کنترل، شاخصی است که ضامن کنترل در آن نشان داده میشود، بسته به تنظیمات، مستقیماً قبل یا بعد از گروه. اگر بیش از یک گروه در یک مکان وجود داشته باشد، کمعمقترین گروه گسترش مییابد.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getActiveRange(); // All row and column groups within the range are expanded. range.expandGroups();
بازگشت
Range — این محدوده، برای زنجیرهسازی.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
getA1Notation()
یک توصیف رشتهای از محدوده را با نمادگذاری A1 برمیگرداند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange(1, 1, 2, 5); // Logs "A1:E2" Logger.log(range.getA1Notation());
بازگشت
String - توصیف رشتهای محدوده با نمادگذاری A1.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Background()
رنگ پسزمینه سلول بالا سمت چپ در محدوده را برمیگرداند (برای مثال، '#ffffff' ).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B5'); Logger.log(cell.getBackground());
بازگشت
String - کد رنگ پس زمینه.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Background Object()
رنگ پسزمینه سلول بالا سمت چپ در محدوده را برمیگرداند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B5'); Logger.log(cell.getBackgroundObject().asRgbColor().asHexString());
بازگشت
Color - رنگ پس زمینه سلول بالا سمت چپ در محدوده.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Background Objects()
رنگهای پسزمینه سلولهای موجود در محدوده را برمیگرداند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B5:C6'); const bgColors = range.getBackgroundObjects(); for (const i in bgColors) { for (const j in bgColors[i]) { Logger.log(bgColors[i][j].asRgbColor().asHexString()); } }
بازگشت
Color[][] — یک آرایه دوبعدی از رنگهای پسزمینه.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Backgrounds()
رنگهای پسزمینه سلولهای موجود در محدوده را برمیگرداند (برای مثال، '#ffffff' ).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B5:C6'); const bgColors = range.getBackgrounds(); for (const i in bgColors) { for (const j in bgColors[i]) { Logger.log(bgColors[i][j]); } }
بازگشت
String[][] — یک آرایه دوبعدی از کدهای رنگی پسزمینهها.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Bandings()
تمام نوارهایی را که برای هر سلول در این محدوده اعمال میشود، برمیگرداند.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Sets a range. const range = sheet.getRange('A1:K50'); // Gets the banding info for the range. const bandings = range.getBandings(); // Logs the second row color for each banding to the console. for (const banding of bandings) { console.log(banding.getSecondRowColor()); }
بازگشت
Banding[] — تمام نوارهایی که برای هر سلول در این محدوده اعمال میشوند.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Cell(row, column)
یک سلول داده شده را در یک محدوده برمیگرداند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); // The row and column here are relative to the range // getCell(1,1) in this code returns the cell at B2 const cell = range.getCell(1, 1); Logger.log(cell.getValue());
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
row | Integer | ردیف سلول نسبت به محدوده. |
column | Integer | ستون سلول نسبت به محدوده. |
بازگشت
Range - محدودهای که شامل یک سلول واحد در مختصات مشخص شده است.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Column()
موقعیت ستون شروع را برای این محدوده برمیگرداند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); // Logs "2.0" Logger.log(range.getColumn());
بازگشت
Integer - موقعیت ستون شروع محدوده در صفحه گسترده.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Data Region()
یک کپی از محدودهای که در چهار Direction اصلی گسترش یافته است را برمیگرداند تا تمام سلولهای مجاور دارای داده را پوشش دهد. اگر محدوده توسط سلولهای خالی احاطه شده باشد، به جز سلولهایی که در امتداد قطرها قرار دارند، خود محدوده برگردانده میشود. این مشابه انتخاب محدوده و تایپ Ctrl+A در ویرایشگر است.
// Assume the active spreadsheet is blank. const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; sheet.getRange('C2').setValue(100); sheet.getRange('B3').setValue(100); sheet.getRange('D3').setValue(100); sheet.getRange('C4').setValue(100); // Logs "B2:D4" Logger.log(sheet.getRange('C3').getDataRegion().getA1Notation());
بازگشت
Range — ناحیه داده محدوده یا محدودهای برای کل صفحه گسترده.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Data Region(dimension)
اگر بُعد مشخص شده Dimension.ROWS باشد، یک کپی از محدودهی گسترشیافتهی Direction.UP و Direction.DOWN را برمیگرداند، یا اگر بُعد Dimension.COLUMNS باشد Direction.NEXT و Direction.PREVIOUS برمیگرداند. گسترش محدوده بر اساس شناسایی دادهها در کنار محدودهای است که مانند یک جدول سازماندهی شده است. محدودهی گسترشیافته تمام سلولهای مجاور را که دادهها در آنها در امتداد بُعد مشخص شده، از جمله مرزهای جدول، قرار دارند، پوشش میدهد. اگر محدودهی اصلی توسط سلولهای خالی در امتداد بُعد مشخص شده احاطه شده باشد، خود محدوده بازگردانده میشود. این روش مشابه انتخاب محدوده و تایپ Ctrl+Space برای ستونها یا Shift+Space برای ردیفها در ویرایشگر است.
// Assume the active spreadsheet is blank. const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; sheet.getRange('C2').setValue(100); sheet.getRange('B3').setValue(100); sheet.getRange('D3').setValue(100); sheet.getRange('C4').setValue(100); // Logs "C2:C4" Logger.log( sheet.getRange('C3') .getDataRegion(SpreadsheetApp.Dimension.ROWS) .getA1Notation(), ); // Logs "B3:D3" Logger.log( sheet.getRange('C3') .getDataRegion(SpreadsheetApp.Dimension.COLUMNS) .getA1Notation(), );
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
dimension | Dimension | بُعدی که میتوان در امتداد آن محدوده را گسترش داد. |
بازگشت
Range — ناحیه دادهای محدوده یا محدودهای که هر ستون یا هر ردیفِ محدوده اصلی را پوشش میدهد.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Data Source Formula()
Data Source Formula برای اولین سلول در محدوده برمیگرداند، یا اگر سلول حاوی فرمول منبع داده نباشد، null برمیگرداند.
// Opens the spreadsheet file by its ID. If you created your script from a // Google Sheets file, use SpreadsheetApp.getActiveSpreadsheet(). // TODO(developer): Replace the ID with your own. const ss = SpreadsheetApp.openById('abc123456'); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1 on Sheet1. const range = sheet.getRange('A1'); // Gets the data source formula from cell A1. const dataSourceFormula = range.getDataSourceFormula(); // Gets the formula. const formula = dataSourceFormula.getFormula(); // Logs the formula. console.log(formula);
بازگشت
Data Source Formula |null — Data Source Formula برای سلول.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Data Source Formulas()
Data Source Formula Formulas) را برای سلولهای موجود در محدوده برمیگرداند.
// Opens the spreadsheet file by its ID. If you created your script from a // Google Sheets file, use SpreadsheetApp.getActiveSpreadsheet(). // TODO(developer): Replace the ID with your own. const ss = SpreadsheetApp.openById('abc123456'); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:B5 on Sheet1. const range = sheet.getRange('A1:B5'); // Gets an array of the data source formulas in the range A1:B5. const dataSourceFormulas = range.getDataSourceFormulas(); // Logs the first formula in the array. console.log(dataSourceFormulas[0].getFormula());
بازگشت
Data Source Formula[] — آرایهای از Data Source Formula .
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Data Source Pivot Tables()
تمام جداول محوری منبع داده که با محدوده تلاقی دارند را دریافت میکند.
// Opens the spreadsheet file by its ID. If you created your script from a // Google Sheets file, use SpreadsheetApp.getActiveSpreadsheet(). // TODO(developer): Replace the ID with your own. const ss = SpreadsheetApp.openById('abc123456'); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:G50 on Sheet1. const range = sheet.getRange('A1:G50'); // Gets an array of the data source pivot tables in the range A1:G50. const dataSourcePivotTables = range.getDataSourcePivotTables(); // Logs the last time that the first pivot table in the array was refreshed. console.log(dataSourcePivotTables[0].getStatus().getLastRefreshedTime());
بازگشت
Data Source Pivot Table[] — فهرستی از جداول محوری منبع داده.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Data Source Tables()
تمام جداول منبع داده که با محدوده تلاقی دارند را دریافت میکند.
// Opens the spreadsheet file by its ID. If you created your script from a // Google Sheets file, use SpreadsheetApp.getActiveSpreadsheet(). // TODO(developer): Replace the ID with your own. const ss = SpreadsheetApp.openById('abc123456'); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:G50 on Sheet1. const range = sheet.getRange('A1:G50'); // Gets the first data source table in the range A1:G50. const dataSourceTable = range.getDataSourceTables()[0]; // Logs the time of the last completed data execution on the data source table. console.log(dataSourceTable.getStatus().getLastExecutionTime());
بازگشت
Data Source Table[] — فهرستی از جداول منبع داده.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Data Source Url()
یک URL برای دادههای موجود در این محدوده برمیگرداند که میتواند برای ایجاد نمودارها و پرسوجوها استفاده شود.
کد.gs
function doGet() { const ss = SpreadsheetApp.openById( '1khO6hBWTNNyvyyxvob7aoZTI9ZvlqqASNeq0e29Tw2c', ); const sheet = ss.getSheetByName('ContinentData'); const range = sheet.getRange('A1:B8'); const template = HtmlService.createTemplateFromFile('piechart'); template.dataSourceUrl = range.getDataSourceUrl(); return template.evaluate(); }
نمودار دایرهای.html
<!DOCTYPE html>
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
// Load the Visualization API and the corechart package.
google.charts.load('current', {'packages': ['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(queryData);
function queryData() {
var query = new google.visualization.Query('<?= dataSourceUrl ?>');
query.send(drawChart);
}
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart(response) {
if (response.isError()) {
alert('Error: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
var data = response.getDataTable();
// Set chart options.
var options = {
title: 'Population by Continent',
width: 400,
height: 300
};
// Instantiate and draw the chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<!-- Div that holds the pie chart. -->
<div id="chart_div"></div>
</body>
</html>بازگشت
String - یک URL برای این محدوده به عنوان منبع داده که میتواند به API های دیگر مانند نمودارها منتقل شود.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Data Table()
دادههای درون این شیء را به عنوان یک DataTable برگردانید.
// Opens the spreadsheet file by its ID. If you created your script from a // Google Sheets file, use SpreadsheetApp.getActiveSpreadsheet(). // TODO(developer): Replace the ID with your own. const ss = SpreadsheetApp.openById('abc123456'); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:B7 on Sheet1. const range = sheet.getRange('A1:B7'); // Gets the range A1:B7 as a data table. The values in each column must be of // the same type. const datatable = range.getDataTable(); // Uses the Charts service to build a bar chart from the data table. // This doesn't build an embedded chart. To do that, use // sheet.newChart().addRange() instead. const chart = Charts.newBarChart() .setDataTable(datatable) .setOption('title', 'Your Chart Title Here') .build();
بازگشت
Data Table — دادهها به عنوان یک جدول داده.
get Data Table(firstRowIsHeader)
دادههای داخل این محدوده را به عنوان یک DataTable برگردانید.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:B7'); // Calling this method with "true" sets the first line to be the title of the // axes const datatable = range.getDataTable(true); // Note that this doesn't build an EmbeddedChart, so you can't just use // Sheet#insertChart(). To do that, use sheet.newChart().addRange() instead. const chart = Charts.newBarChart() .setDataTable(datatable) .setOption('title', 'Your Title Here') .build();
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
first Row Is Header | Boolean | اینکه آیا ردیف اول به عنوان سرصفحه در نظر گرفته شود یا خیر. |
بازگشت
Data Table - دادهها به عنوان یک جدول داده.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Data Validation()
قانون اعتبارسنجی دادهها را برای سلول بالا سمت چپ در محدوده برمیگرداند. اگر اعتبارسنجی دادهها روی سلول تنظیم نشده باشد، این متد null را برمیگرداند.
// Log information about the data validation rule for cell A1. const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = cell.getDataValidation(); if (rule != null) { const criteria = rule.getCriteriaType(); const args = rule.getCriteriaValues(); Logger.log('The data validation rule is %s %s', criteria, args); } else { Logger.log('The cell does not have a data validation rule.'); }
بازگشت
Data Validation - قانون اعتبارسنجی دادهها برای سلول بالا سمت چپ در محدوده.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Data Validations()
قوانین اعتبارسنجی دادهها را برای همه سلولهای موجود در محدوده برمیگرداند. اگر اعتبارسنجی دادهها روی یک سلول مشخص تنظیم نشده باشد، این متد برای موقعیت آن سلول در آرایه null را برمیگرداند.
// Change existing data validation rules that require a date in 2013 to require // a date in 2014. const oldDates = [new Date('1/1/2013'), new Date('12/31/2013')]; const newDates = [new Date('1/1/2014'), new Date('12/31/2014')]; const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns()); const rules = range.getDataValidations(); for (let i = 0; i < rules.length; i++) { for (let j = 0; j < rules[i].length; j++) { const rule = rules[i][j]; if (rule != null) { const criteria = rule.getCriteriaType(); const args = rule.getCriteriaValues(); if (criteria === SpreadsheetApp.DataValidationCriteria.DATE_BETWEEN && args[0].getTime() === oldDates[0].getTime() && args[1].getTime() === oldDates[1].getTime()) { // Create a builder from the existing rule, then change the dates. rules[i][j] = rule.copy().withCriteria(criteria, newDates).build(); } } } } range.setDataValidations(rules);
بازگشت
Data Validation[][] — یک آرایه دوبعدی از قوانین اعتبارسنجی دادهها که با سلولهای موجود در محدوده مرتبط هستند.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Developer Metadata()
متادیتای توسعهدهندهی مرتبط با این محدوده را دریافت میکند.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets row 2 on Sheet1. const range = sheet.getRange('2:2'); // Adds metadata to row 2. range.addDeveloperMetadata('NAME', 'GOOGLE'); // Logs the metadata to console. for (const metadata of range.getDeveloperMetadata()) { console.log(`${metadata.getKey()}: ${metadata.getValue()}`); }
بازگشت
Developer Metadata[] — فراداده توسعهدهنده مرتبط با این محدوده.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Display Value()
مقدار نمایش داده شده سلول بالا سمت چپ در محدوده را برمیگرداند. مقدار یک String است. مقدار نمایش داده شده، قالببندی تاریخ، زمان و واحد پول، از جمله قالبهایی که به طور خودکار توسط تنظیمات محلی صفحه گسترده اعمال میشوند را در نظر میگیرد. سلولهای خالی یک رشته خالی برمیگردانند.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets cell A30 and sets its value to 'Test code.' const cell = sheet.getRange('A30'); cell.setValue('Test code'); // Gets the value and logs it to the console. console.log(cell.getDisplayValue());
بازگشت
String - مقدار نمایش داده شده در این سلول.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Display Values()
شبکه مستطیلی مقادیر را برای این محدوده برمیگرداند.
یک آرایه دو بعدی از مقادیر نمایش داده شده را برمیگرداند که ابتدا بر اساس سطر و سپس بر اساس ستون فهرستبندی شدهاند. مقادیر، اشیاء String هستند. مقدار نمایش داده شده، قالببندی تاریخ، زمان و واحد پول، از جمله قالبهایی که به طور خودکار توسط تنظیمات محلی صفحه گسترده اعمال میشوند را در نظر میگیرد. سلولهای خالی با یک رشته خالی در آرایه نمایش داده میشوند. به یاد داشته باشید که در حالی که یک فهرست محدوده از 1, 1 شروع میشود، آرایه جاوا اسکریپت از [0][0] فهرستبندی میشود.
// The code below gets the displayed values for the range C2:G8 // in the active spreadsheet. Note that this is a JavaScript array. const values = SpreadsheetApp.getActiveSheet().getRange(2, 3, 6, 4).getDisplayValues(); Logger.log(values[0][0]);
بازگشت
String[][] — یک آرایه دو بعدی از مقادیر.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Filter()
فیلتر روی شیتی که این محدوده به آن تعلق دارد را برمیگرداند، یا اگر فیلتری روی شیت وجود نداشته باشد null برمیگرداند.
const ss = SpreadsheetApp.getActiveSheet(); const range = ss.getRange('A1:C20'); // Gets the existing filter on the sheet that the given range belongs to. const filter = range.getFilter();
بازگشت
Filter |null — فیلتر.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Font Color Object()
رنگ فونت سلول را در گوشه بالا سمت چپ محدوده برمیگرداند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getFontColorObject().asRgbColor().asHexString());
بازگشت
Color - رنگ فونت سلول بالا سمت چپ در محدوده.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Font Color Objects()
رنگ فونت سلولهای موجود در محدوده را برمیگرداند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getFontColorObjects(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j].asRgbColor().asHexString()); } }
بازگشت
Color[][] — یک آرایه دوبعدی از رنگهای فونت مرتبط با سلولهای موجود در محدوده.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Font Families()
خانوادههای فونت سلولهای موجود در محدوده را برمیگرداند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getFontFamilies(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
بازگشت
String[][] — یک آرایه دوبعدی از خانوادههای فونت مرتبط با سلولهای موجود در محدوده.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Font Family()
خانواده فونت سلول را در گوشه بالا سمت چپ محدوده برمیگرداند.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getFontFamily());
بازگشت
String — The font family of the cell.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Font Line()
Gets the line style of the cell in the top-left corner of the range ( 'underline' , 'line-through' , or 'none' ).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getFontLine());
بازگشت
String — The font line.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Font Lines()
Gets the line style of the cells in the range ( 'underline' , 'line-through' , or 'none' ).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getFontLines(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
بازگشت
String[][] — A two-dimensional array of font lines associated with cells in the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Font Size()
Returns the font size in point size of the cell in the top-left corner of the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getFontSize());
بازگشت
Integer — The font size in point size.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Font Sizes()
Returns the font sizes of the cells in the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getFontSizes(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
بازگشت
Integer[][] — A two-dimensional array of font sizes of text associated with cells in the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Font Style()
Returns the font style ( 'italic' or 'normal' ) of the cell in the top-left corner of the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getFontStyle());
بازگشت
String — The font style of the text in the cell.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Font Styles()
Returns the font styles of the cells in the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getFontStyles(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
بازگشت
String[][] — A two-dimensional array of font styles of text associated with cells in the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Font Weight()
Returns the font weight (normal/bold) of the cell in the top-left corner of the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getFontWeight());
بازگشت
String — The font weight of the text in the cell.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Font Weights()
Returns the font weights of the cells in the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getFontWeights(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
بازگشت
String[][] — A two-dimensional array of font weights of text associated with cells in the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Formula()
Returns the formula (A1 notation) for the top-left cell of the range, or an empty string if the cell is empty or doesn't contain a formula.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This assumes you have a function in B5 that sums up // B2:B4 const range = sheet.getRange('B5'); // Logs the calculated value and the formula Logger.log( 'Calculated value: %s Formula: %s', range.getValue(), range.getFormula(), );
بازگشت
String — The formula for the cell.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Formula R1C1()
Returns the formula (R1C1 notation) for a given cell, or null if none.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B5'); const formula = range.getFormulaR1C1(); Logger.log(formula);
بازگشت
String — The formula in R1C1 notation.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Formulas()
Returns the formulas (A1 notation) for the cells in the range. Entries in the 2D array are empty strings for cells with no formula.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B5:C6'); const formulas = range.getFormulas(); for (const i in formulas) { for (const j in formulas[i]) { Logger.log(formulas[i][j]); } }
بازگشت
String[][] — A two-dimensional array of formulas in string format.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Formulas R1C1()
Returns the formulas (R1C1 notation) for the cells in the range. Entries in the 2D array are null for cells with no formula.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B5:C6'); const formulas = range.getFormulasR1C1(); for (const i in formulas) { for (const j in formulas[i]) { Logger.log(formulas[i][j]); } }
بازگشت
String[][] — A two-dimensional array of formulas in R1C1 notation.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Grid Id()
Returns the grid ID of the range's parent sheet. IDs are random non-negative int values.
// Log the grid ID of the first sheet (by tab position) in the spreadsheet. const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getGridId());
بازگشت
Integer — The grid ID of the parent sheet.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Height()
Returns the height of the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); // logs 3.0 Logger.log(range.getHeight());
بازگشت
Integer — The height of the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Horizontal Alignment()
Returns the horizontal alignment of the text (left/center/right) of the cell in the top-left corner of the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getHorizontalAlignment());
بازگشت
String — The horizontal alignment of the text in the cell.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Horizontal Alignments()
Returns the horizontal alignments of the cells in the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getHorizontalAlignments(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
بازگشت
String[][] — A two-dimensional array of horizontal alignments of text associated with cells in the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Last Column()
Returns the end column position.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); // Logs "4.0" Logger.log(range.getLastColumn());
بازگشت
Integer — The range's ending column position in the spreadsheet.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Last Row()
Returns the end row position.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); // Logs "4.0" Logger.log(range.getLastRow());
بازگشت
Integer — The range's ending row position in the spreadsheet.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Merged Ranges()
Returns an array of Range objects representing merged cells that either are fully within the current range, or contain at least one cell in the current range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:B3'); const mergedRanges = range.getMergedRanges(); for (let i = 0; i < mergedRanges.length; i++) { Logger.log(mergedRanges[i].getA1Notation()); Logger.log(mergedRanges[i].getDisplayValue()); }
بازگشت
Range[] — An array of Range objects, representing merged cells overlapping the range.
get Next Data Cell(direction)
Starting at the cell in the first column and row of the range, returns the next cell in the given direction that is the edge of a contiguous range of cells with data in them or the cell at the edge of the spreadsheet in that direction. This is equivalent to typing Ctrl+[arrow key] in the editor.
// Assume the active spreadsheet is blank. const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('C3:E5'); // Logs "C1" Logger.log(range.getNextDataCell(SpreadsheetApp.Direction.UP).getA1Notation());
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
direction | Direction | The direction in which to find the next data region edge cell. |
بازگشت
Range — The data region edge cell or the cell at the edge of the spreadsheet.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Note()
Returns the note associated with the given range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getNote());
بازگشت
String — The note associated with the given cell.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Notes()
Returns the notes associated with the cells in the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getNotes(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
بازگشت
String[][] — A two-dimensional array of notes associated with cells in the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Num Columns()
Returns the number of columns in this range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D5'); Logger.log(range.getNumColumns());
بازگشت
Integer — The number of columns in this range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Num Rows()
Returns the number of rows in this range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D5'); Logger.log(range.getNumRows());
بازگشت
Integer — The number of rows in this range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Number Format()
Get the number or date formatting of the top-left cell of the given range. The returned format patterns are described in the Sheets API documentation .
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('C4'); Logger.log(cell.getNumberFormat());
بازگشت
String — The number format of the top-left cell of the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Number Formats()
Returns the number or date formats for the cells in the range. The returned format patterns are described in the Sheets API documentation .
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B5:C6'); const formats = range.getNumberFormats(); for (const i in formats) { for (const j in formats[i]) { Logger.log(formats[i][j]); } }
بازگشت
String[][] — A two-dimensional array of number formats.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Rich Text Value()
Returns the Rich Text value for the top left cell of the range, or null if the cell value is not text.
// Gets the Rich Text value of cell D4. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('D4:F6'); const richText = range.getRichTextValue(); console.log(richText.getText());
بازگشت
Rich Text Value |null — The Rich Text value of the top left cell in the range, or null if the cell value is not text.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Rich Text Values()
Returns the Rich Text values for the cells in the range.
// Gets the Rich Text values for all cells in range B5:C6 const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B5:C6'); const values = range.getRichTextValues(); for (let i = 0; i < values.length; i++) { for (let j = 0; j < values[i].length; j++) { console.log(values[i][j].getText()); } }
بازگشت
Rich Text Value[][] — A two-dimensional array of Rich Text values.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Row()
Returns the row position for this range. Identical to get Row Index() .
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2'); Logger.log(range.getRow());
بازگشت
Integer — The row position of the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Row Index()
Returns the row position for this range. Identical to get Row() .
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2'); Logger.log(range.getRowIndex());
بازگشت
Integer — The row position of the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
همچنین ببینید
get Sheet()
Returns the sheet this range belongs to.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Gets the sheet that the range belongs to. const rangeSheet = range.getSheet(); // Gets the sheet name and logs it to the console. console.log(rangeSheet.getName());
بازگشت
Sheet — The sheet that this range belongs to.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Text Direction()
Returns the text direction for the top left cell of the range. Returns null if the cell text direction is determined with automatic detection.
// Get the text direction of cell B1. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B1:D4'); Logger.log(range.getTextDirection());
بازگشت
Text Direction — The text direction of the top left cell in the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Text Directions()
Returns the text directions for the cells in the range. Entries in the 2D array are null for cells using automatic detection.
// Get the text directions for all cells in range B5:C6 const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B5:C6'); const directions = range.getTextDirections(); for (let i = 0; i < directions.length; i++) { for (let j = 0; j < directions[i].length; j++) { Logger.log(directions[i][j]); } }
بازگشت
Text Direction[][] — A two-dimensional array of text directions.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Text Rotation()
Returns the text rotation settings for the top left cell of the range.
// Log the text rotation settings for a cell. const sheet = SpreadsheetApp.getActiveSheet(); const cell = sheet.getRange('A1'); Logger.log(cell.getTextRotation());
بازگشت
Text Rotation — The text rotation settings.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Text Rotations()
Returns the text rotation settings for the cells in the range.
const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B2:D4'); const results = range.getTextRotations(); for (const i in results) { for (const j in results[i]) { const rotation = results[i][j]; Logger.log('Cell [%s, %s] has text rotation: %v', i, j, rotation); } }
بازگشت
Text Rotation[][] — A two-dimensional array of text rotations associated with cells in the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Text Style()
Returns the text style for the top left cell of the range.
// Get the text style of cell D4. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('D4:F6'); const style = range.getTextStyle(); Logger.log(style);
بازگشت
Text Style — The text style of the top left cell in the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Text Styles()
Returns the text styles for the cells in the range.
// Get the text styles for all cells in range B5:C6 const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B5:C6'); const styles = range.getTextStyles(); for (let i = 0; i < styles.length; i++) { for (let j = 0; j < styles[i].length; j++) { Logger.log(styles[i][j]); } }
بازگشت
Text Style[][] — A two-dimensional array of text styles.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Value()
Returns the value of the top-left cell in the range. The value may be of type Number , Boolean , Date , or String depending on the value of the cell. Empty cells return an empty string.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Gets the value of the top-left cell in the range and logs it to the console. console.log(range.getValue());
بازگشت
Object — The value in this cell.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Values()
Returns the rectangular grid of values for this range.
Returns a two-dimensional array of values, indexed by row, then by column. The values may be of type Number , Boolean , Date , or String , depending on the value of the cell. Empty cells are represented by an empty string in the array. Remember that while a range index starts at 1, 1 , the JavaScript array is indexed from [0][0] .
// The code below gets the values for the range C2:G8 // in the active spreadsheet. Note that this is a JavaScript array. const values = SpreadsheetApp.getActiveSheet().getRange(2, 3, 6, 4).getValues(); Logger.log(values[0][0]);
Date value isn't a legal parameter. get Values() fails to return data to a web app if the range contains a cell with a Date value. Instead, transform all the values retrieved from the sheet to a supported JavaScript primitive like a Number , Boolean , or String .بازگشت
Object[][] — A two-dimensional array of values.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Vertical Alignment()
Returns the vertical alignment (top/middle/bottom) of the cell in the top-left corner of the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getVerticalAlignment());
بازگشت
String — The vertical alignment of the text in the cell.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Vertical Alignments()
Returns the vertical alignments of the cells in the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getVerticalAlignments(); for (const i in results) { for (const j in results[i]) { Logger.log(results[i][j]); } }
بازگشت
String[][] — A two-dimensional array of vertical alignments of text associated with cells in the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Width()
Returns the width of the range in columns.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Gets the width of the range in number of columns and logs it to the console. console.log(range.getWidth());
بازگشت
Integer — The number of columns in the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Wrap()
Returns whether the text in the cell wraps. To get more granular wrap strategy, use get Wrap Strategy() .
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getWrap());
بازگشت
Boolean — Whether the text in this cell wraps or not.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Wrap Strategies()
Returns the text wrapping strategies for the cells in the range.
// Get the text wrapping strategies for all cells in range B5:C6 const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B5:C6'); const strategies = range.getWrapStrategies(); for (let i = 0; i < strategies.length; i++) { for (let j = 0; j < strategies[i].length; j++) { Logger.log(strategies[i][j]); } }
بازگشت
Wrap Strategy[][] — A two-dimensional array of text wrapping strategies.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Wrap Strategy()
Returns the text wrapping strategy for the top left cell of the range.
// Get the text wrapping strategy of cell B1. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B1:D4'); Logger.log(range.getWrapStrategy());
بازگشت
Wrap Strategy — The text wrapping strategy of the top left cell in the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Wraps()
Returns whether the text in the cells wrap. To get more granular wrap strategy, use get Wrap Strategies() .
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); const results = range.getVerticalAlignments(); for (const i in results) { for (const j in results[i]) { const isWrapped = results[i][j]; if (isWrapped) { Logger.log('Cell [%s, %s] has wrapped text', i, j); } } }
بازگشت
Boolean[][] — A two-dimensional array of vertical alignments of text associated with cells in the range.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
insert Cells(shiftDimension)
Inserts empty cells into this range. The new cells retain any formatting present in the cells previously occupying this range. Existing data in the sheet along the provided dimension is shifted away from the inserted range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:D10'); range.insertCells(SpreadsheetApp.Dimension.COLUMNS);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
shift Dimension | Dimension | The dimension along which to shift existing data. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
insert Checkboxes()
Inserts checkboxes into each cell in the range, configured with true for checked and false for unchecked. Sets the value of all cells in the range to false .
const range = SpreadsheetApp.getActive().getRange('A1:B10'); // Inserts checkboxes into each cell in the range A1:B10 configured with 'true' // for checked and 'false' for unchecked. Also, sets the value of each cell in // the range A1:B10 to 'false'. range.insertCheckboxes();
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
insert Checkboxes(checkedValue)
Inserts checkboxes into each cell in the range, configured with a custom value for checked and the empty string for unchecked. Sets the value of each cell in the range to the empty string.
const range = SpreadsheetApp.getActive().getRange('A1:B10'); // Inserts checkboxes into each cell in the range A1:B10 configured with 'yes' // for checked and the empty string for unchecked. Also, sets the value of each // cell in the range A1:B10 to // the empty string. range.insertCheckboxes('yes');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
checked Value | Object | The checked value for the checkbox data validation. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
insert Checkboxes(checkedValue, uncheckedValue)
Inserts checkboxes into each cell in the range, configured with custom values for the checked and unchecked states. Sets the value of each cell in the range to the custom unchecked value.
const range = SpreadsheetApp.getActive().getRange('A1:B10'); // Inserts checkboxes into each cell in the range A1:B10 configured with 'yes' // for checked and 'no' for unchecked. Also, sets the value of each cell in the // range A1:B10 to 'no'. range.insertCheckboxes('yes', 'no');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
checked Value | Object | The checked value for the checkbox data validation. |
unchecked Value | Object | The unchecked value for the checkbox data validation. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
is Blank()
Returns true if the range is totally blank.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.isBlank());
بازگشت
Boolean — true if the range is blank; false otherwise.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
is Checked()
Returns whether all cells in the range have their checkbox state as 'checked'. Returns null if some cells are checked and the rest unchecked, or if some cells do not have checkbox data validation.
const range = SpreadsheetApp.getActive().getRange('A1:A3'); // Inserts checkboxes and sets each cell value to 'no' in the range A1:A3. range.insertCheckboxes('yes', 'no'); const range1 = SpreadsheetApp.getActive().getRange('A1'); range1.setValue('yes'); // Sets the value of isRange1Checked as true as it contains the checked value. const isRange1Checked = range1.isChecked(); const range2 = SpreadsheetApp.getActive().getRange('A2'); range2.setValue('no'); // Sets the value of isRange2Checked as false as it contains the unchecked // value. const isRange2Checked = range2.isChecked(); const range3 = SpreadsheetApp.getActive().getRange('A3'); range3.setValue('random'); // Sets the value of isRange3Checked as null, as it contains an invalid checkbox // value. const isRange3Checked = range3.isChecked();
بازگشت
Boolean — true , if all cells in the range are checked, false if all cells in the range are unchecked, or null if any of the cells are unchecked or do not have checkbox data validation.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
is End Column Bounded()
Determines whether the end of the range is bound to a particular column. For example, for the ranges A1:B10 or B:B , which are bound to columns at the end of the range, this method returns true ; for the ranges 3:7 or A1:5 , which are bound only to particular rows at the end of the range, this method returns false .
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Determines if the end of the range is bound to a particular column and logs // it to the console. console.log(range.isEndColumnBounded());
بازگشت
Boolean — true if the end of the range is bound to a particular column; false otherwise.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
is End Row Bounded()
Determines whether the end of the range is bound to a particular row. For example, for the ranges A1:B10 or 3:7 , which are bound to rows at the end of the range, this method returns true ; for the ranges B:B or A1:C , which are bound only to particular columns at the end of the range, this method returns false .
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Determines if the end of the range is bound to a particular row and logs it // to the console. console.log(range.isEndRowBounded());
بازگشت
Boolean — true if the end of the range is bound to a particular row; false otherwise.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
is Part Of Merge()
Returns true if the cells in the current range overlap any merged cells.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:B3'); // True if any of the cells in A1:B3 is included in a merge. const isPartOfMerge = range.isPartOfMerge();
بازگشت
Boolean — true if the range overlaps any merged cells, otherwise returns false .
is Start Column Bounded()
Determines whether the start of the range is bound to a particular column. For example, for the ranges A1:B10 or B:B , which are bound to columns at the start of the range, this method returns true ; for the range 3:7 , which is bound only to a row at the start of the range, this method returns false .
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Determines if the start of the range is bound to a particular column and logs // it to the console. console.log(range.isStartColumnBounded());
بازگشت
Boolean — true if the start of the range is bound to a particular column; false otherwise.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
is Start Row Bounded()
Determines whether the start of the range is bound to a particular row. For example, for the ranges A1:B10 or 3:7 , which are bound to rows at the start of the range, this method returns true ; for the range B:B , which is bound only to a particular column at the start of the range, this method returns false .
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets the range A1:D10 on Sheet1. const range = sheet.getRange('A1:D10'); // Determines if the start of the range is bound to a particular row and logs it // to the console. console.log(range.isStartRowBounded());
بازگشت
Boolean — true if the start of the range is bound to a particular row; false otherwise.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
merge()
Merges the cells in the range together into a single block.
const sheet = SpreadsheetApp.getActiveSheet(); // The code below 2-dimensionally merges the cells in A1 to B3 sheet.getRange('A1:B3').merge();
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
merge Across()
Merge the cells in the range across the columns of the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The code below merges cells C5:E5 into one cell const range1 = sheet.getRange('C5:E5'); range1.mergeAcross(); // The code below creates 2 horizontal cells, F5:H5 and F6:H6 const range2 = sheet.getRange('F5:H6'); range2.mergeAcross();
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
merge Vertically()
Merges the cells in the range together.
const sheet = SpreadsheetApp.getActiveSheet(); // The code below vertically merges the cells in A1 to A10 sheet.getRange('A1:A10').mergeVertically(); // The code below creates 3 merged columns: B1 to B10, C1 to C10, and D1 to D10 sheet.getRange('B1:D10').mergeVertically();
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
move To(target)
Cut and paste (both format and values) from this range to the target range.
// The code below moves the first 5 columns over to the 6th column const sheet = SpreadsheetApp.getActiveSheet(); sheet.getRange('A1:E').moveTo(sheet.getRange('F1'));
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
target | Range | A target range to copy this range to; only the top-left cell position is relevant. |
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
offset(rowOffset, columnOffset)
Returns a new range that is offset from this range by the given number of rows and columns (which can be negative). The new range is the same size as the original range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('A1'); // newCell references B2 const newCell = cell.offset(1, 1);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
row Offset | Integer | The number of rows down from the range's top-left cell; negative values represent rows up from the range's top-left cell. |
column Offset | Integer | The number of columns right from the range's top-left cell; negative values represent columns left from the range's top-left cell. |
بازگشت
Range — This range, for chaining.
offset(rowOffset, columnOffset, numRows)
Returns a new range that is relative to the current range, whose upper left point is offset from the current range by the given rows and columns, and with the given height in cells.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('A1'); // newCell references B2:B3 const newRange = cell.offset(1, 1, 2);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
row Offset | Integer | The number of rows down from the range's top-left cell; negative values represent rows up from the range's top-left cell. |
column Offset | Integer | The number of columns right from the range's top-left cell; negative values represent columns left from the range's top-left cell. |
num Rows | Integer | The height in rows of the new range. |
بازگشت
Range — This range, for chaining.
offset(rowOffset, columnOffset, numRows, numColumns)
Returns a new range that is relative to the current range, whose upper left point is offset from the current range by the given rows and columns, and with the given height and width in cells.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('A1'); // newCell references B2:C3 const newRange = cell.offset(1, 1, 2, 2);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
row Offset | Integer | The number of rows down from the range's top-left cell; negative values represent rows up from the range's top-left cell. |
column Offset | Integer | The number of columns right from the range's top-left cell; negative values represent columns left from the range's top-left cell. |
num Rows | Integer | The height in rows of the new range. |
num Columns | Integer | The width in columns of the new range. |
بازگشت
Range — This range, for chaining.
protect()
Creates an object that can protect the range from being edited except by users who have permission. Until the script actually changes the list of editors for the range (by calling Protection.removeEditor(emailAddress) , Protection.removeEditor(user) , Protection.removeEditors(emailAddresses) , Protection.addEditor(emailAddress) , Protection.addEditor(user) , Protection.addEditors(emailAddresses) , or setting a new value for Protection.setDomainEdit(editable) ), the permissions mirror those of the spreadsheet itself, which effectively means that the range remains unprotected. If the range is already protected, this method creates a new protected range that overlaps the existing one. If a cell is protected by multiple protected ranges and any of them prevent a particular user from editing the cell, then that user is not permitted to edit the cell.
// Protect range A1:B10, then remove all other users from the list of editors. const ss = SpreadsheetApp.getActive(); const range = ss.getRange('A1:B10'); const protection = range.protect().setDescription('Sample protected range'); // Ensure the current user is an editor before removing others. Otherwise, if // the user's edit permission comes from a group, the script throws an exception // upon removing the group. const me = Session.getEffectiveUser(); protection.addEditor(me); protection.removeEditors(protection.getEditors()); if (protection.canDomainEdit()) { protection.setDomainEdit(false); }
بازگشت
Protection — An object representing the protection settings.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
randomize()
Randomizes the order of the rows in the given range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:C7'); // Randomizes the range range.randomize();
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
remove Checkboxes()
Removes all checkboxes from the range. Clears the data validation of each cell, and additionally clears its value if the cell contains either the checked or unchecked value.
const range = SpreadsheetApp.getActive().getRange('A1:B10'); // Inserts checkboxes and sets each cell value to 'no' in the range A1:B10. range.insertCheckboxes('yes', 'no'); const range1 = SpreadsheetApp.getActive().getRange('A1'); range1.setValue('yes'); // Removes the checkbox data validation in cell A1 and clears its value. range1.removeCheckboxes(); const range2 = SpreadsheetApp.getActive().getRange('A2'); range2.setValue('random'); // Removes the checkbox data validation in cell A2 but does not clear its value. range2.removeCheckboxes();
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
remove Duplicates()
Removes rows within this range that contain values that are duplicates of values in any previous row. Rows with identical values but different letter cases, formatting, or formulas are considered to be duplicates. This method also removes duplicates rows hidden from view (for example, due to a filter). Content outside of this range isn't removed.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B1:D7'); // Remove duplicate rows in the range. range.removeDuplicates();
بازگشت
Range — The resulting range after removing duplicates. The size of the range is reduced by a row for every row removed.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
remove Duplicates(columnsToCompare)
Removes rows within this range that contain values in the specified columns that are duplicates of values any previous row. Rows with identical values but different letter cases, formatting, or formulas are considered to be duplicates. This method also removes duplicates rows hidden from view (for example, due to a filter). Content outside of this range isn't removed.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B1:D7'); // Remove rows which have duplicate values in column B. range.removeDuplicates([2]); // Remove rows which have duplicate values in both columns B and D. range.removeDuplicates([2, 4]);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
columns To Compare | Integer[] | The columns to analyze for duplicate values. If no columns are provided then all columns are analyzed for duplicates. |
بازگشت
Range — The resulting range after removing duplicates. The size of the range is reduced by a row for every row removed.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Background(color)
Sets the background color of all cells in the range in CSS notation (such as '#ffffff' or 'white' ).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D5'); range.setBackground('red');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
color | String | A color code in CSS notation (such as '#ffffff' or 'white' ); a null value resets the color. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Background Object(color)
Sets the background color of all cells in the range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const bgColor = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND) .build(); const range = sheet.getRange('B2:D5'); range.setBackgroundObject(bgColor);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
color | Color | The background color to set; null value resets the background color. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Background Objects(color)
Sets a rectangular grid of background colors (must match dimensions of this range).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const colorAccent1 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); const colorAccent2 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2) .build(); const colorAccent3 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3) .build(); const colorAccent4 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT4) .build(); const colors = [ [colorAccent1, colorAccent2], [colorAccent3, colorAccent4], ]; const cell = sheet.getRange('B5:C6'); cell.setBackgroundObjects(colors);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
color | Color[][] | A two-dimensional array of colors; null values reset the color. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Background RGB(red, green, blue)
Sets the background to the given color using RGB values (integers between 0 and 255 inclusive).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); // Sets the background to white cell.setBackgroundRGB(255, 255, 255); // Sets the background to red cell.setBackgroundRGB(255, 0, 0);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
red | Integer | The red value in RGB notation. |
green | Integer | The green value in RGB notation. |
blue | Integer | The blue value in RGB notation. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Backgrounds(color)
Sets a rectangular grid of background colors (must match dimensions of this range). The colors are in CSS notation (such as '#ffffff' or 'white' ).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const colors = [ ['red', 'white', 'blue'], ['#FF0000', '#FFFFFF', '#0000FF'], // These are the hex equivalents ]; const cell = sheet.getRange('B5:D6'); cell.setBackgrounds(colors);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
color | String[][] | A two-dimensional array of colors in CSS notation (such as '#ffffff' or 'white' ); null values reset the color. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Border(top, left, bottom, right, vertical, horizontal)
Sets the border property. Valid values are true (on), false (off) and null (no change).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); // Sets borders on the top and bottom, but leaves the left and right unchanged cell.setBorder(true, null, true, null, false, false);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
top | Boolean | true for border, false for none, null for no change. |
left | Boolean | true for border, false for none, null for no change. |
bottom | Boolean | true for border, false for none, null for no change. |
right | Boolean | true for border, false for none, null for no change. |
vertical | Boolean | true for internal vertical borders, false for none, null for no change. |
horizontal | Boolean | true for internal horizontal borders, false for none, null for no change. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Border(top, left, bottom, right, vertical, horizontal, color, style)
Sets the border property with color and/or style. Valid values are true (on), false (off) and null (no change). For color, use Color in CSS notation (such as '#ffffff' or 'white' ).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); // Sets borders on the top and bottom, but leaves the left and right unchanged // Also sets the color to "red", and the border to "DASHED". cell.setBorder( true, null, true, null, false, false, 'red', SpreadsheetApp.BorderStyle.DASHED, );
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
top | Boolean | true for border, false for none, null for no change. |
left | Boolean | true for border, false for none, null for no change. |
bottom | Boolean | true for border, false for none, null for no change. |
right | Boolean | true for border, false for none, null for no change. |
vertical | Boolean | true for internal vertical borders, false for none, null for no change. |
horizontal | Boolean | true for internal horizontal borders, false for none, null for no change. |
color | String | A color in CSS notation (such as '#ffffff' or 'white' ), null for default color (black). |
style | Border Style | A style for the borders, null for default style (solid). |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Data Validation(rule)
Sets one data validation rule for all cells in the range.
// Set the data validation rule for cell A1 to require a value from B1:B10. const cell = SpreadsheetApp.getActive().getRange('A1'); const range = SpreadsheetApp.getActive().getRange('B1:B10'); const rule = SpreadsheetApp.newDataValidation().requireValueInRange(range).build(); cell.setDataValidation(rule);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
rule | Data Validation | The data validation rule to set, or null to remove data validation. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Data Validations(rules)
Sets the data validation rules for all cells in the range. This method takes a two-dimensional array of data validations, indexed by row then by column. The array dimensions must correspond to the range dimensions.
// Set the data validation rules for Sheet1!A1:B5 to require a value from // Sheet2!A1:A10. const destinationRange = SpreadsheetApp.getActive().getSheetByName('Sheet1').getRange('A1:B5'); const sourceRange = SpreadsheetApp.getActive().getSheetByName('Sheet2').getRange('A1:A10'); const rule = SpreadsheetApp.newDataValidation().requireValueInRange(sourceRange).build(); const rules = destinationRange.getDataValidations(); for (let i = 0; i < rules.length; i++) { for (let j = 0; j < rules[i].length; j++) { rules[i][j] = rule; } } destinationRange.setDataValidations(rules);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
rules | Data Validation[][] | A two-dimensional array of data validation rules to set; null values remove data validation. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Color(color)
Sets the font color in CSS notation (such as '#ffffff' or 'white' ).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setFontColor('red');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
color | String | The font color in CSS notation (such as '#ffffff' or 'white' ); a null value resets the color. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Color Object(color)
Sets the font color of the given range.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const color = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT) .build(); const cell = sheet.getRange('B2'); cell.setFontColor(color);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
color | Color | The font color to set; a null value resets the color. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Color Objects(colors)
Sets a rectangular grid of font colors (must match dimensions of this range).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const colorAccent1 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1) .build(); const colorAccent2 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2) .build(); const colorAccent3 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3) .build(); const colorAccent4 = SpreadsheetApp.newColor() .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT4) .build(); const colors = [ [colorAccent1, colorAccent2], [colorAccent3, colorAccent4], ]; const cell = sheet.getRange('B5:C6'); cell.setFontColorObjects(colors);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
colors | Color[][] | A two-dimensional array of colors; null values reset the font color. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Colors(colors)
Sets a rectangular grid of font colors (must match dimensions of this range). The colors are in CSS notation (such as '#ffffff' or 'white' ).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const colors = [ ['red', 'white', 'blue'], ['#FF0000', '#FFFFFF', '#0000FF'], // These are the hex equivalents ]; const cell = sheet.getRange('B5:D6'); cell.setFontColors(colors);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
colors | Object[][] | A two-dimensional array of colors in CSS notation (such as '#ffffff' or 'white' ); null values reset the color. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Families(fontFamilies)
Sets a rectangular grid of font families (must match dimensions of this range). Examples of font families are "Arial" or "Helvetica".
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const fonts = [ ['Arial', 'Helvetica', 'Verdana'], ['Courier New', 'Arial', 'Helvetica'], ]; const cell = sheet.getRange('B2:D3'); cell.setFontFamilies(fonts);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
font Families | Object[][] | A two-dimensional array of font families; null values reset the font family. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Family(fontFamily)
Sets the font family, such as "Arial" or "Helvetica".
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setFontFamily('Helvetica');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
font Family | String | The font family to set; a null value resets the font family. |
بازگشت
Range — This range, for chaining.
مجوز
اسکریپتهایی که از این روش استفاده میکنند، نیاز به مجوز با یک یا چند مورد از حوزههای زیر دارند:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Line(fontLine)
Sets the font line style of the given range ( 'underline' , 'line-through' , or 'none' ).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setFontLine('line-through');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
font Line | String | The font line style, either 'underline' , 'line-through' , or 'none' ; a null value resets the font line style. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Lines(fontLines)
Sets a rectangular grid of line styles (must match dimensions of this range).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const fontLines = [['underline', 'line-through', 'none']]; const range = sheet.getRange('B2:D2'); range.setFontLines(fontLines);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
font Lines | Object[][] | A two-dimensional array of font line styles ( 'underline' , 'line-through' , or 'none' ); null values reset the font line style. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Size(size)
Sets the font size, with the size being the point size to use.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setFontSize(20);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
size | Integer | A font size in point size. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Sizes(sizes)
Sets a rectangular grid of font sizes (must match dimensions of this range). The sizes are in points.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const fontSizes = [[16, 20, 24]]; const range = sheet.getRange('B2:D2'); range.setFontSizes(fontSizes);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
sizes | Object[][] | A two-dimensional array of sizes. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Style(fontStyle)
Set the font style for the given range ( 'italic' or 'normal' ).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setFontStyle('italic');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
font Style | String | The font style, either 'italic' or 'normal' ; a null value resets the font style. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Styles(fontStyles)
Sets a rectangular grid of font styles (must match dimensions of this range).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const fontStyles = [['italic', 'normal']]; const range = sheet.getRange('B2:C2'); range.setFontStyles(fontStyles);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
font Styles | Object[][] | A two-dimensional array of font styles, either 'italic' or 'normal' ; null values reset the font style. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Weight(fontWeight)
Set the font weight for the given range (normal/bold).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setFontWeight('bold');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
font Weight | String | The font weight, either 'bold' or 'normal' ; a null value resets the font weight. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Font Weights(fontWeights)
Sets a rectangular grid of font weights (must match dimensions of this range). An example of a font weight is "bold".
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const fontStyles = [['bold', 'bold', 'normal']]; const range = sheet.getRange('B2:D2'); range.setFontWeights(fontStyles);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
font Weights | Object[][] | A two-dimensional array of font weights, either 'bold' or 'normal' ; null values reset the font weight. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Formula(formula)
Updates the formula for this range. The given formula must be in A1 notation.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B5'); cell.setFormula('=SUM(B3:B4)');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
formula | String | A string representing the formula to set for the cell. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Formula R1C1(formula)
Updates the formula for this range. The given formula must be in R1C1 notation.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B5'); // This sets the formula to be the sum of the 3 rows above B5 cell.setFormulaR1C1('=SUM(R[-3]C[0]:R[-1]C[0])');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
formula | String | A string formula. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Formulas(formulas)
Sets a rectangular grid of formulas (must match dimensions of this range). The given formulas must be in A1 notation. This method takes a two-dimensional array of formulas, indexed by row, then by column. The array dimensions must correspond to the range dimensions.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This sets the formulas to be a row of sums, followed by a row of averages // right below. The size of the two-dimensional array must match the size of the // range. const formulas = [ ['=SUM(B2:B4)', '=SUM(C2:C4)', '=SUM(D2:D4)'], ['=AVERAGE(B2:B4)', '=AVERAGE(C2:C4)', '=AVERAGE(D2:D4)'], ]; const cell = sheet.getRange('B5:D6'); cell.setFormulas(formulas);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
formulas | String[][] | A two-dimensional string array of formulas. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Formulas R1C1(formulas)
Sets a rectangular grid of formulas (must match dimensions of this range). The given formulas must be in R1C1 notation.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // This creates formulas for a row of sums, followed by a row of averages. const sumOfRowsAbove = '=SUM(R[-3]C[0]:R[-1]C[0])'; const averageOfRowsAbove = '=AVERAGE(R[-4]C[0]:R[-2]C[0])'; // The size of the two-dimensional array must match the size of the range. const formulas = [ [sumOfRowsAbove, sumOfRowsAbove, sumOfRowsAbove], [averageOfRowsAbove, averageOfRowsAbove, averageOfRowsAbove], ]; const cell = sheet.getRange('B5:D6'); // This sets the formula to be the sum of the 3 rows above B5. cell.setFormulasR1C1(formulas);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
formulas | String[][] | A two-dimensional array of formulas in R1C1 format. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Horizontal Alignment(alignment)
Set the horizontal (left to right) alignment for the given range (left/center/right).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setHorizontalAlignment('center');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
alignment | String | The alignment, either 'left' , 'center' or 'normal' ; a null value resets the alignment. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Horizontal Alignments(alignments)
Sets a rectangular grid of horizontal alignments. see set Horizontal Alignment(alignment)
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const horizontalAlignments = [['left', 'right', 'center']]; const range = sheet.getRange('B2:D2'); range.setHorizontalAlignments(horizontalAlignments);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
alignments | Object[][] | A two-dimensional array of alignments, either 'left' , 'center' or 'normal' ; a null value resets the alignment. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
همچنین ببینید
set Note(note)
Sets the note to the given value.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setNote('This is a note');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
note | String | The note value to set for the range; a null value removes the note. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Notes(notes)
Sets a rectangular grid of notes (must match dimensions of this range).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const notes = [ ['it goes', 'like this', 'the fourth, the fifth'], ['the minor fall', 'and the', 'major lift'], ]; const cell = sheet.getRange('B2:D3'); cell.setNotes(notes);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
notes | Object[][] | A two-dimensional array of notes; null values remove the note. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
همچنین ببینید
set Number Format(numberFormat)
Sets the number or date format to the given formatting string. The accepted format patterns are described in the Sheets API documentation .
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); // Always show 3 decimal points cell.setNumberFormat('0.000');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
number Format | String | A number format string. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Number Formats(numberFormats)
Sets a rectangular grid of number or date formats (must match dimensions of this range). The values are format pattern strings as described in the Sheets API documentation .
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const formats = [['0.000', '0,000,000', '$0.00']]; const range = sheet.getRange('B2:D2'); range.setNumberFormats(formats);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
number Formats | Object[][] | A two-dimensional array of number formats. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Rich Text Value(value)
Sets the Rich Text value for the cells in the range.
// Sets all cells in range B2:D4 to have the text "Hello world", with "Hello" // bolded. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B2:D4'); const bold = SpreadsheetApp.newTextStyle().setBold(true).build(); const richText = SpreadsheetApp.newRichTextValue() .setText('Hello world') .setTextStyle(0, 5, bold) .build(); range.setRichTextValue(richText);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
value | Rich Text Value | The desired Rich Text value. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Rich Text Values(values)
Sets a rectangular grid of Rich Text values.
// Sets the cells in range A1:A2 to have Rich Text values. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:A2'); const bold = SpreadsheetApp.newTextStyle().setBold(true).build(); const italic = SpreadsheetApp.newTextStyle().setItalic(true).build(); const richTextA1 = SpreadsheetApp.newRichTextValue() .setText('This cell is bold') .setTextStyle(bold) .build(); const richTextA2 = SpreadsheetApp.newRichTextValue() .setText('bold words, italic words') .setTextStyle(0, 11, bold) .setTextStyle(12, 24, italic) .build(); range.setRichTextValues([[richTextA1], [richTextA2]]);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
values | Rich Text Value[][] | The desired Rich Text values. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Show Hyperlink(showHyperlink)
Sets whether or not the range should show hyperlinks.
// Opens the spreadsheet file by its URL. If you created your script from within // a Google Sheets file, you can useSpreadsheetApp.getActiveSpreadsheet() // instead. // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); // Gets Sheet1 by its name. const sheet = ss.getSheetByName('Sheet1'); // Gets cell A30 and sets its hyperlink value. const range = sheet.getRange('A30'); range.setValue('https://www.example.com'); // Sets cell A30 to show hyperlinks. range.setShowHyperlink(true);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
show Hyperlink | Boolean | Whether or not to show the hyperlink. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Text Direction(direction)
Sets the text direction for the cells in the range. If a specified direction is null , the direction is inferred and then set.
// Sets right-to-left text direction for the range. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B5:C6'); range.setTextDirection(SpreadsheetApp.TextDirection.RIGHT_TO_LEFT);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
direction | Text Direction | The desired text direction; if null the direction is inferred before setting. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Text Directions(directions)
Sets a rectangular grid of text directions. If a specified direction is null , the direction is inferred and then set.
// Copies all of the text directions from range A1:B2 over to range C5:D6. const sheet = SpreadsheetApp.getActiveSheet(); const range1 = sheet.getRange('A1:B2'); const range2 = sheet.getRange('C5:D6'); range2.setTextRotations(range1.getTextDirections());
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
directions | Text Direction[][] | The desired text directions; if a specified direction is null it is inferred before setting. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Text Rotation(degrees)
Sets the text rotation settings for the cells in the range. The input corresponds to the angle between the standard text orientation and the desired orientation. An input of zero indicates that the text is set to the standard orientation.
For left to right text direction, positive angles are in the counterclockwise direction, whereas for right to left they are in the clockwise direction.
// Sets all cell's in range B2:D4 to have text rotated up 45 degrees. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B2:D4'); range.setTextRotation(45);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
degrees | Integer | The desired angle between the standard orientation and the desired orientation. For left to right text, positive angles are in the counterclockwise direction. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Text Rotation(rotation)
Sets the text rotation settings for the cells in the range.
// Sets all cell's in range B2:D4 to have the same text rotation settings as // cell A1. const sheet = SpreadsheetApp.getActiveSheet(); const rotation = sheet.getRange('A1').getTextRotation(); sheet.getRange('B2:D4').setTextRotation(rotation);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
rotation | Text Rotation | The desired text rotation settings. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Text Rotations(rotations)
Sets a rectangular grid of text rotations.
// Copies all of the text rotations from range A1:B2 over to range C5:D6. const sheet = SpreadsheetApp.getActiveSheet(); const range1 = sheet.getRange('A1:B2'); const range2 = sheet.getRange('C5:D6'); range2.setTextRotations(range1.getTextRotations());
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
rotations | Text Rotation[][] | The desired text rotation settings. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Text Style(style)
Sets the text style for the cells in the range.
// Sets the cells in range C5:D6 to have underlined size 15 font. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('C5:D6'); const style = SpreadsheetApp.newTextStyle().setFontSize(15).setUnderline(true).build(); range.setTextStyle(style);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
style | Text Style | The desired text style. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Text Styles(styles)
Sets a rectangular grid of text styles.
// Sets text styles for cells in range A1:B2 const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('A1:B2'); const bold = SpreadsheetApp.newTextStyle().setBold(true).build(); const otherStyle = SpreadsheetApp.newTextStyle() .setBold(true) .setUnderline(true) .setItalic(true) .setForegroundColor('#335522') .setFontSize(44) .build(); range.setTextStyles([ [bold, otherStyle], [otherStyle, bold], ]);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
styles | Text Style[][] | The desired text styles. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Value(value)
Sets the value of the range. The value can be numeric, string, boolean or date. If it begins with '=' it is interpreted as a formula.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setValue(100);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
value | Object | The value for the range. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Values(values)
Sets a rectangular grid of values (must match dimensions of this range). If a value begins with = , it's interpreted as a formula.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const values = [['2.000', '1,000,000', '$2.99']]; const range = sheet.getRange('B2:D2'); range.setValues(values);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
values | Object[][] | A two-dimensional array of values. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Vertical Alignment(alignment)
Set the vertical (top to bottom) alignment for the given range (top/middle/bottom).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setVerticalAlignment('middle');
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
alignment | String | The alignment, either 'top' , 'middle' or 'bottom' ; a null value resets the alignment. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Vertical Alignments(alignments)
Sets a rectangular grid of vertical alignments (must match dimensions of this range).
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const alignments = [['top', 'middle', 'bottom']]; const range = sheet.getRange('B2:D2'); range.setVerticalAlignments(alignments);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
alignments | Object[][] | A two-dimensional array of alignments, either 'top' , 'middle' or 'bottom' ; a null value resets the alignment. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
همچنین ببینید
set Vertical Text(isVertical)
Sets whether or not to stack the text for the cells in the range. If the text is stacked vertically, the degree text rotation setting is ignored.
// Sets all cell's in range B2:D4 to have vertically stacked text. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B2:D4'); range.setVerticalText(true);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
is Vertical | Boolean | Whether or not to stack the text. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Wrap(isWrapEnabled)
Set the cell wrap of the given range.
Cells with wrap enabled (the default) resize to display their full content. Cells with wrap disabled display as much as possible in the cell without resizing or running to multiple lines.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const cell = sheet.getRange('B2'); cell.setWrap(true);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
is Wrap Enabled | Boolean | Whether to wrap text or not. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Wrap Strategies(strategies)
Sets a rectangular grid of wrap strategies.
// Copies all of the wrap strategies from range A1:B2 over to range C5:D6. const sheet = SpreadsheetApp.getActiveSheet(); const range1 = sheet.getRange('A1:B2'); const range2 = sheet.getRange('C5:D6'); range2.setWrapStrategies(range1.getWrapStrategies());
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
strategies | Wrap Strategy[][] | The desired wrapping strategies. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Wrap Strategy(strategy)
Sets the text wrapping strategy for the cells in the range.
// Sets all cells in range B2:D4 to use the clip wrap strategy. const sheet = SpreadsheetApp.getActiveSheet(); const range = sheet.getRange('B2:D4'); range.setWrapStrategy(SpreadsheetApp.WrapStrategy.CLIP);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
strategy | Wrap Strategy | The desired wrapping strategy. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Wraps(isWrapEnabled)
Sets a rectangular grid of word wrap policies (must match dimensions of this range). Cells with wrap enabled (the default) resize to display their full content. Cells with wrap disabled display as much as possible in the cell without resizing or running to multiple lines.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; // The size of the two-dimensional array must match the size of the range. const wraps = [[true, true, false]]; const range = sheet.getRange('B2:D2'); range.setWraps(wraps);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
is Wrap Enabled | Object[][] | A two-dimensional array of wrap variables that determine whether to wrap text in a cell or not. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
همچنین ببینید
shift Column Group Depth(delta)
Changes the column grouping depth of the range by the specified amount.
This has the effect of creating, modifying, or deleting groups that intersect with the range. For positive deltas, groups are created and/or modified; for negative deltas, groups are destroyed and/or modified.
This has no effect when decreasing the group depth below zero or above eight.
If the column group control position is BEFORE , this throws an error when attempting to shift the depth of the first row.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getActiveRange(); // The column grouping depth is increased by 1. range.shiftColumnGroupDepth(1); // The column grouping depth is decreased by 1. range.shiftColumnGroupDepth(-1);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
delta | Integer | The amount by which to change the column group depth of this range. |
بازگشت
Range — This range, for chaining.
پرتابها
Error — when attempting to shift the depth of the first column when the control position is Group Control Toggle Position.BEFORE
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
shift Row Group Depth(delta)
Changes the row grouping depth of the range by the specified amount.
This has the effect of creating, modifying, or deleting groups that intersect with the range. For positive deltas, groups are created and/or modified; for negative deltas, groups are destroyed and/or modified.
This has no effect when decreasing the group depth below zero or above eight.
If the row group control position is BEFORE , this throws an error when attempting to shift the depth of the first row.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getActiveRange(); // The row grouping depth is increased by 1. range.shiftRowGroupDepth(1); // The row grouping depth is decreased by 1. range.shiftRowGroupDepth(-1);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
delta | Integer | The amount by which to change the row group depth of this range. |
بازگشت
Range — This range, for chaining.
پرتابها
Error — when attempting to shift the depth of the first row when the control position is Group Control Toggle Position.BEFORE
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
sort(sortSpecObj)
Sorts the cells in the given range, by column and order specified.
const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('A1:C7'); // Sorts by the values in the first column (A) range.sort(1); // Sorts by the values in the second column (B) range.sort(2); // Sorts descending by column B range.sort({column: 2, ascending: false}); // Sorts descending by column B, then ascending by column A // Note the use of an array range.sort([ {column: 2, ascending: false}, {column: 1, ascending: true}, ]); // For rows that are sorted in ascending order, the "ascending" parameter is // optional, and just an integer with the column can be used instead. Note that // in general, keeping the sort specification consistent results in more // readable code. You can express the earlier sort as: range.sort([{column: 2, ascending: false}, 1]); // Alternatively, if you want all columns to be in ascending order, you can use // the following (this makes column 2 ascending) range.sort([2, 1]); // ... which is equivalent to range.sort([ {column: 2, ascending: true}, {column: 1, ascending: true}, ]);
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
sort Spec Obj | Object | The columns to sort by. |
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
split Text To Columns()
Splits a column of text into multiple columns based on an auto-detected delimiter.
// A1:A3 has the following values: // A B C // 1 |one,one,one | | | // 2 |two,two,two | | | // 3 |three,three,three| | | const range = SpreadsheetApp.getActiveSheet().getRange('A1:A3'); range.splitTextToColumns(); // Result after splitting the text to columns: // A B C // 1 |one |one |one | // 2 |two |two |two | // 3 |three |three |three |
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
split Text To Columns(delimiter)
Splits a column of text into multiple columns using the specified string as a custom delimiter.
// A1:A3 has the following values: // A B C // 1 |one#one#one | | | // 2 |two#two#two | | | // 3 |three#three#three| | | const range = SpreadsheetApp.getActiveSheet().getRange('A1:A3'); range.splitTextToColumns('#'); // Result after splitting the text to columns: // A B C // 1 |one |one |one | // 2 |two |two |two | // 3 |three |three |three |
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
delimiter | String | The custom delimiter to split on. |
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
split Text To Columns(delimiter)
Splits a column of text into multiple columns based on the specified delimiter.
// A1:A3 has the following values: // A B C // 1 |one;one;one | | | // 2 |two;two;two | | | // 3 |three;three;three| | | const range = SpreadsheetApp.getActiveSheet().getRange('A1:A3'); range.splitTextToColumns(SpreadsheetApp.TextToColumnsDelimiter.SEMICOLON); // Result after splitting the text to columns: // A B C // 1 |one |one |one | // 2 |two |two |two | // 3 |three |three |three |
پارامترها
| نام | نوع | توضیحات |
|---|---|---|
delimiter | Text To Columns Delimiter | The preset delimiter to split on. |
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
trim Whitespace()
Trims the whitespace (such as spaces, tabs, or new lines) in every cell in this range. Removes all whitespace from the start and end of each cell's text, and reduces any subsequence of remaining whitespace characters to a single space.
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]; const range = sheet.getRange('A1:A4'); range.activate(); range.setValues([ ' preceding space', 'following space ', 'two middle spaces', ' =SUM(1,2)', ]); range.trimWhitespace(); const values = range.getValues(); // Values are ['preceding space', 'following space', 'two middle spaces', // '=SUM(1,2)']
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
uncheck()
Changes the state of the checkboxes in the range to “unchecked”. Ignores the cells in the range which currently do not contain either the checked or unchecked value configured.
// Changes the state of cells which currently contain either the checked or // unchecked value configured in the range A1:B10 to 'unchecked'. const range = SpreadsheetApp.getActive().getRange('A1:B10'); range.uncheck();
بازگشت
Range — This range, for chaining.
مجوز
Scripts that use this method require authorization with one or more of the following scopes :
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets