تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
أقنعة الحقول هي طريقة تتيح لمستخدمي واجهة برمجة التطبيقات إدراج الحقول التي يجب أن يعرضها الطلب أو يعدّلها. يسمح استخدام
FieldMask
لواجهة برمجة التطبيقات بتجنُّب العمل غير الضروري وتحسين الأداء. يتم استخدام قناع الحقل لكلّ من طريقتَي القراءة والتعديل في Google Sheets API.
يكون تنسيق المَعلمة fields هو نفسه ترميز JSON الخاص بـ FieldMask.
باختصار، يتم الفصل بين الحقول المختلفة المتعددة باستخدام الفواصل، بينما يتم الفصل بين الحقول الفرعية باستخدام النقاط. يمكن تحديد أسماء الحقول باستخدام camelCase أو
separated_by_underscores. لتسهيل الأمر، يمكن إدراج حقول فرعية متعددة من النوع نفسه بين قوسين.
يستخدم مثال طلب spreadsheets.get التالي قناع حقل sheets.properties(sheetId,title,sheetType,gridProperties) لاسترداد رقم تعريف ورقة البيانات وعنوانها وSheetType وGridProperties لكائن SheetProperties في جميع أوراق البيانات في جدول بيانات:
GET https://sheets.googleapis.com/v4/spreadsheets/spreadsheetId?fields=sheets.properties(sheetId,title,sheetType,gridProperties)
الردّ على طلب استدعاء هذه الطريقة هو كائن
Spreadsheet
يحتوي على المكوّنات المطلوبة في قناع الحقل. يُرجى العِلم أنّ
sheetType=OBJECT لا يحتوي على gridProperties:
في بعض الأحيان، تحتاج إلى تعديل حقول معيّنة فقط في أحد العناصر مع ترك الحقول الأخرى بدون تغيير. تستخدم طلبات التعديل ضِمن عملية spreadsheets.batchUpdate أقنعة الحقول لإخبار واجهة برمجة التطبيقات بالحقول التي يتم تغييرها. يتجاهل طلب التعديل أي حقول غير محدّدة في قناع الحقل، ويتركها بقيمها الحالية.
يمكنك أيضًا إلغاء ضبط حقل من خلال عدم تحديده في الرسالة المعدَّلة، ولكن مع إضافة الحقل إلى القناع. يؤدي ذلك إلى محو أي قيمة كان يتضمّنها الحقل سابقًا.
تكون بنية أقنعة الحقول المعدَّلة هي نفسها بنية أقنعة الحقول للقراءة.
.
يستخدم المثال التالي
AddSheetRequest
لإضافة ورقة جديدة من النوع Grid وتجميد الصف الأول وتلوين علامة التبويب الخاصة بالورقة الجديدة باللون الأحمر:
POST https://sheets.googleapis.com/v1/spreadsheets/spreadsheetId:batchUpdate
تاريخ التعديل الأخير: 2025-08-29 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-29 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Use field masks\n\nField masks are a way for API callers to list the fields that a request should\nreturn or update. Using a\n[FieldMask](https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask)\nallows the API to avoid unnecessary work and improves performance. A field mask\nis used for both the read and update methods in the Google Sheets API.\n\nRead with a field mask\n----------------------\n\nSpreadsheets can be large, and often you don't need every part of the\n[`Spreadsheet`](/workspace/sheets/api/reference/rest/v4/spreadsheets#resource:-spreadsheet)\nresource returned by a read request. You can limit what's returned in a\nSheets API response, using the `fields` URL parameter. For best\nperformance, [explicitly list only the fields you\nneed](/workspace/sheets/api/guides/performance#partial-response) in the reply.\n\nThe format of the fields parameter is the same as the [JSON encoding of a\nFieldMask](https://protobuf.dev/reference/protobuf/google.protobuf/#json-encoding-field-masks).\nStated briefly, multiple different fields are comma-separated and subfields are\ndot-separated. Field names can be specified in **camelCase** or\n**separated_by_underscores**. For convenience, multiple subfields from the same\ntype can be listed within parentheses.\n\nThe following\n[`spreadsheets.get`](/workspace/sheets/api/reference/rest/v4/spreadsheets/get)\nrequest example uses a field mask of\n`sheets.properties(sheetId,title,sheetType,gridProperties)` to fetch only the\nsheet ID, title,\n[`SheetType`](/workspace/sheets/api/reference/rest/v4/spreadsheets/sheets#SheetType),\nand\n[`GridProperties`](/workspace/sheets/api/reference/rest/v4/spreadsheets/sheets#GridProperties)\nof a\n[`SheetProperties`](/workspace/sheets/api/reference/rest/v4/spreadsheets/sheets#SheetProperties)\nobject on all sheets in a spreadsheet: \n\n```\nGET https://sheets.googleapis.com/v4/spreadsheets/spreadsheetId?fields=sheets.properties(sheetId,title,sheetType,gridProperties)\n```\n\nThe response to this method call is a\n[`Spreadsheet`](/workspace/sheets/api/reference/rest/v4/spreadsheets#resource:-spreadsheet)\nobject containing the components requested in the field mask. Note that\n`sheetType=OBJECT` doesn't contain `gridProperties`: \n\n {\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": \u003cvar translate=\"no\"\u003eSHEET_ID\u003c/var\u003e,\n \"title\": \"\u003cvar translate=\"no\"\u003eTITLE\u003c/var\u003e\",\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 25\n }\n }\n },\n {\n \"properties\": {\n \"sheetId\": \u003cvar translate=\"no\"\u003eSHEET_ID\u003c/var\u003e,\n \"title\": \"\u003cvar translate=\"no\"\u003eTITLE\u003c/var\u003e\",\n \"sheetType\": \"OBJECT\"\n }\n }\n ]\n }\n\nUpdate with a field mask\n------------------------\n\nSometimes you need to update only certain fields in an object while leaving the\nother fields unchanged. Update requests inside a\n[`spreadsheets.batchUpdate`](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate)\noperation use field masks to tell the API which fields are being changed. The\nupdate request ignores any fields that aren't specified in the field mask,\nleaving them with their current values.\n\nYou can also unset a field by not specifying it in the updated message, but\nadding the field to the mask. This clears whatever value the field previously\nhad.\n\nThe syntax for update field masks is the same as read field masks.\n| A field mask of `*` is treated like a wildcard and is shorthand for specifying every field in a message. The wildcard syntax can produce unwanted results if the API is updated in the future, as read-only fields and newly added fields may cause errors. For production applications, always list the specific fields being updated in field masks and avoid using `*` wildcards.\n\nThe following example uses the\n[`AddSheetRequest`](/workspace/sheets/api/reference/rest/v4/spreadsheets/request#addsheetrequest)\nto add a new sheet of type `Grid`, freeze the first row, and color the new\nsheet's tab red: \n\n```\nPOST https://sheets.googleapis.com/v1/spreadsheets/spreadsheetId:batchUpdate\n``` \n\n {\n \"spreadsheetId\": \"\u003cvar translate=\"no\"\u003eSPREADSHEET_ID\u003c/var\u003e\",\n \"replies\": [\n {\n \"addSheet\": {\n \"properties\": {\n \"sheetId\": \u003cvar translate=\"no\"\u003eSHEET_ID\u003c/var\u003e,\n \"title\": \"\u003cvar translate=\"no\"\u003eTITLE\u003c/var\u003e\",\n \"index\": 6,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26,\n \"frozenRowCount\": 1\n },\n \"tabColor\": {\n \"red\": 0.003921569\n },\n \"tabColorStyle\": {\n \"rgbColor\": {\n \"red\": 0.003921569\n }\n }\n }\n }\n }\n ]\n }"]]