Class PivotFilter
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ตัวกรองPivot
เข้าถึงและแก้ไขตัวกรองตาราง Pivot
เอกสารโดยละเอียด
getFilterCriteria()
แสดงผลเกณฑ์ตัวกรองสำหรับตัวกรอง Pivot นี้
รีเทิร์น
FilterCriteria
— เกณฑ์ตัวกรองสำหรับตัวกรอง Pivot นี้
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getPivotTable()
แสดง PivotTable
ที่ตัวกรองนี้เป็นของ
รีเทิร์น
PivotTable
— ตาราง Pivot ที่ตัวกรองนี้เป็นของ
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSourceDataColumn()
แสดงผลหมายเลขคอลัมน์ข้อมูลต้นฉบับที่ตัวกรองนี้ทำงาน ดัชนีเหล่านี้เป็นแบบ
อิงตาม 1 เช่น หากตัวกรองนี้ใช้กับข้อมูลในคอลัมน์ A ของสเปรดชีต เมธอดนี้
จะแสดงผล "1"
รีเทิร์น
Integer
— จำนวนคอลัมน์ข้อมูลต้นทางที่ตัวกรองนี้ใช้
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSourceDataSourceColumn()
แสดงผลคอลัมน์แหล่งข้อมูลที่ตัวกรองทํางาน แสดงผล null
หากตาราง Pivot
ไม่ใช่ {DataSourcePivotTableApi}
รีเทิร์น
DataSourceColumn
— คอลัมน์แหล่งข้อมูลที่ตัวกรองทำงาน
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
remove()
นำตัวกรอง Pivot นี้ออกจากตาราง Pivot
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setFilterCriteria(filterCriteria)
กำหนดเกณฑ์ตัวกรองสำหรับตัวกรอง Pivot นี้
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
filterCriteria | FilterCriteria | เกณฑ์ตัวกรองที่จะตั้งค่า |
รีเทิร์น
PivotFilter
- ตัวกรองการหมุนสำหรับการเชื่อมโยง
การให้สิทธิ์
สคริปต์ที่ใช้วิธีนี้ต้องมีการให้สิทธิ์ที่มีขอบเขตต่อไปนี้อย่างน้อย 1 รายการ
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-13 UTC
[null,null,["อัปเดตล่าสุด 2025-08-13 UTC"],[[["\u003cp\u003e\u003ccode\u003ePivotFilter\u003c/code\u003e objects provide methods to access and modify filters applied to pivot tables in Google Sheets.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve filter criteria, identify the associated pivot table and source data column, and remove the filter using dedicated methods.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003esetFilterCriteria()\u003c/code\u003e method allows you to define specific filtering conditions for the pivot table data.\u003c/p\u003e\n"],["\u003cp\u003eThese methods require authorization with specific scopes to interact with Google Sheets data.\u003c/p\u003e\n"]]],[],null,["# Class PivotFilter\n\nPivotFilter\n\nAccess and modify pivot table filters. \n\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------------------------------------------|---------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|\n| [getFilterCriteria()](#getFilterCriteria()) | [FilterCriteria](/apps-script/reference/spreadsheet/filter-criteria) | Returns the filter criteria for this pivot filter. |\n| [getPivotTable()](#getPivotTable()) | [PivotTable](/apps-script/reference/spreadsheet/pivot-table) | Returns the [PivotTable](/apps-script/reference/spreadsheet/pivot-table) that this filter belongs to. |\n| [getSourceDataColumn()](#getSourceDataColumn()) | `Integer` | Returns the number of the source data column this filter operates on. |\n| [getSourceDataSourceColumn()](#getSourceDataSourceColumn()) | [DataSourceColumn](/apps-script/reference/spreadsheet/data-source-column) | Returns the data source column the filter operates on. |\n| [remove()](#remove()) | `void` | Removes this pivot filter from the pivot table. |\n| [setFilterCriteria(filterCriteria)](#setFilterCriteria(FilterCriteria)) | [PivotFilter](#) | Sets the filter criteria for this pivot filter. |\n\nDetailed documentation\n----------------------\n\n### `get``Filter``Criteria()`\n\nReturns the filter criteria for this pivot filter.\n\n#### Return\n\n\n[FilterCriteria](/apps-script/reference/spreadsheet/filter-criteria) --- The filter criteria for this pivot filter.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Pivot``Table()`\n\nReturns the [PivotTable](/apps-script/reference/spreadsheet/pivot-table) that this filter belongs to.\n\n#### Return\n\n\n[PivotTable](/apps-script/reference/spreadsheet/pivot-table) --- The pivot table this filter belongs to.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Source``Data``Column()`\n\nReturns the number of the source data column this filter operates on. These indices are\n1-based, for example if this filter applies to data in column A of the spreadsheet this method\nreturns \"1.\"\n\n#### Return\n\n\n`Integer` --- The number of the source data column this filter applies to.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Source``Data``Source``Column()`\n\nReturns the data source column the filter operates on. Returns `null` if the pivot table\nis not a {DataSourcePivotTableApi}.\n\n#### Return\n\n\n[DataSourceColumn](/apps-script/reference/spreadsheet/data-source-column) --- The data source column the filter operates on.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `remove()`\n\nRemoves this pivot filter from the pivot table.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `set``Filter``Criteria(filterCriteria)`\n\nSets the filter criteria for this pivot filter.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------------------|----------------------------------------------------------------------|-----------------------------|\n| `filter``Criteria` | [FilterCriteria](/apps-script/reference/spreadsheet/filter-criteria) | The filter criteria to set. |\n\n#### Return\n\n\n[PivotFilter](#) --- The pivot filter for chaining.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`"]]