सैंपल
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
इस सेक्शन में, Google Sheets API के बारे में जानने के लिए codelab दिया गया है. साथ ही, "रेसिपी" के कुछ उदाहरण भी दिए गए हैं. इनसे पता चलता है कि Google Sheets में की जाने वाली किसी कार्रवाई को एपीआई अनुरोध में कैसे बदला जाता है.
अक्सर, एपीआई की मदद से किसी टास्क को पूरा करने के एक से ज़्यादा तरीके होते हैं. किसी टास्क को पूरा करने का तरीका तय करते समय, इन बातों का ध्यान रखें:
- अगर आपको सेल की वैल्यू पढ़नी या लिखनी हैं, तो
spreadsheets.values
कलेक्शन, spreadsheets
कलेक्शन से बेहतर विकल्प है. पहले वाले इंटरफ़ेस को, सामान्य रीड/राइट ऑपरेशन के लिए इस्तेमाल करना आसान होता है.
जहां भी हो सके, बैच वाले तरीकों (spreadsheet.batchUpdate
, spreadsheet.values.batchGet
, और spreadsheet.values.batchUpdate
) का इस्तेमाल करें, ताकि कई अनुरोधों को एक ही तरीके से कॉल किया जा सके. बैच वाले इन तरीकों का इस्तेमाल करने से, काम करने की क्षमता बेहतर होती है. ऐसा इसलिए, क्योंकि:
- क्लाइंट के एचटीटीपी ओवरहेड को कम करें.
- की गई क्वेरी की संख्या कम करें.
- दस्तावेज़ में किए गए बदलावों की संख्या कम करें.
- पक्का करें कि बैच में किए गए सभी बदलावों को एक साथ लागू किया जाए.
रेसिपी
इस सेक्शन में दिए गए उदाहरणों से पता चलता है कि Sheets में की जाने वाली सामान्य कार्रवाइयों को Sheets API v4 के अनुरोधों के तौर पर कैसे दिखाया जाता है.
इन उदाहरणों को एचटीटीपी अनुरोधों के तौर पर दिखाया गया है, ताकि ये किसी भाषा पर आधारित न हों. Google API क्लाइंट लाइब्रेरी का इस्तेमाल करके, किसी खास भाषा में Sheets API के अनुरोध प्रोटोकॉल लागू करने का तरीका जानने के लिए, सेल की वैल्यू पढ़ना और लिखना और स्प्रेडशीट अपडेट करना गाइड देखें.
इस सेक्शन में मौजूद रेसिपी को इन कैटगरी में बांटा गया है:
- बेसिक रीडिंग—ऐसी रेसिपी जो यह दिखाती हैं कि किसी शीट से वैल्यू कैसे पढ़ी जाती हैं.
- लिखने की बुनियादी बातें—ऐसी रेसिपी जो यह दिखाती हैं कि किसी शीट में वैल्यू कैसे लिखी जाती हैं.
- बुनियादी फ़ॉर्मैटिंग—रेसिपी में बताया गया है कि शीट और सेल का लुक कैसे बदला जाए.
- चार्ट—इन रेसिपी में, किसी शीट में चार्ट बनाने और उनमें बदलाव करने का तरीका बताया गया है.
- कंडिशनल फ़ॉर्मैटिंग—
ऐसे तरीके जिनसे शर्तों के आधार पर सेल के दिखने के तरीके को बदला जा सकता है.
- डेटा से जुड़े ऑपरेशन—ऐसी रेसिपी जो यह दिखाती हैं कि स्प्रेडशीट में डेटा कैसे बनाया, ट्रांसफ़र किया, और उसमें बदलाव किया जाता है.
- नाम वाली और सुरक्षित की गई रेंज—ऐसी रेसिपी जो स्प्रेडशीट में नाम वाली और सुरक्षित की गई रेंज बनाने, अपडेट करने, और हटाने का तरीका दिखाती हैं.
- पिवट टेबल—ये ऐसे निर्देश होते हैं जिनमें शीट में पिवट टेबल बनाने का तरीका बताया जाता है.
- लाइन और कॉलम से जुड़े ऑपरेशन—इन रेसिपी में, लाइनें और कॉलम जोड़ने, हटाने, और मूव करने का तरीका बताया गया है. साथ ही, इनकी प्रॉपर्टी अपडेट करने का तरीका भी बताया गया है.
- शीट से जुड़ी कार्रवाइयां—ऐसी रेसिपी जिनसे पता चलता है कि शीट कैसे बनाई जाती हैं, उनका डेटा कैसे मिटाया जाता है, उन्हें कैसे कॉपी किया जाता है, और उन्हें कैसे मिटाया जाता है. साथ ही, उनकी प्रॉपर्टी को कैसे कंट्रोल किया जाता है.
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-08-29 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-08-29 (UTC) को अपडेट किया गया."],[],[],null,["# Samples\n\nThis section presents a\n[codelab](https://codelabs.developers.google.com/codelabs/sheets-api/) you can\nuse to become familiar with the Google Sheets API. Also provided are a set of\n\"recipe\" examples that demonstrate how to translate an intended Google Sheets\naction into an API request.\n\nOften there's more than one way to complete a given task with the API. When\nyou're deciding on how to approach a task, keep the following in mind:\n\n- If you need to read or write cell values, the [`spreadsheets.values`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values) collection is a better choice than the [`spreadsheets`](/workspace/sheets/api/reference/rest/v4/spreadsheets) collection. The former's interface is easier to use for simple read/write operations.\n- Wherever possible, use the batch methods\n ([`spreadsheet.batchUpdate`](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate),\n [`spreadsheet.values.batchGet`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/batchGet),\n and\n [`spreadsheet.values.batchUpdate`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/batchUpdate))\n to bundle multiple requests into a single method call. Using these batch\n methods improves efficiency as they:\n\n - Reduce client HTTP overhead.\n - Reduce the number of queries made.\n - Reduce the number of revisions on the doc.\n - Ensure atomicity of all the changes in the batch.\n\nRecipes\n-------\n\nThe examples listed in this section demonstrate how to express common actions in\nSheets as Sheets API v4 requests.\n\nThese examples are presented in the form of HTTP requests to be language\nneutral. To learn how to implement Sheets API request protocols in a\nspecific language using Google API client libraries, see the [Read \\& write cell\nvalues](/workspace/sheets/api/guides/values) and [Update\nspreadsheets](/workspace/sheets/api/guides/batchupdate) guides.\n\nRecipes in this section are divided into the following categories:\n\n- [Basic reading](/workspace/sheets/api/samples/reading)---Recipes that show how to read values from a sheet.\n- [Basic writing](/workspace/sheets/api/samples/writing)---Recipes that show how to write values to a sheet.\n- [Basic formatting](/workspace/sheets/api/samples/formatting)---Recipes that show how to change the appearance of sheets and cells.\n- [Charts](/workspace/sheets/api/samples/charts)---Recipes that show how to create and alter charts in a sheet.\n- [Conditional formatting](/workspace/sheets/api/samples/conditional-formatting)--- Recipes that show how to alter cell appearance based on conditions.\n- [Data operations](/workspace/sheets/api/samples/data)---Recipes that show how to create, move, and manipulate data in a spreadsheet.\n- [Named \\& protected\n ranges](/workspace/sheets/api/samples/ranges)---Recipes that show how to create, update, and remove named and protected ranges in a spreadsheet.\n- [Pivot tables](/workspace/sheets/api/samples/pivot-tables)---Recipes that show how to create pivot tables in a sheet.\n- [Row \\& column\n operations](/workspace/sheets/api/samples/rowcolumn)---Recipes that show how to add, remove, and move rows and columns, and update their properties.\n- [Sheet operations](/workspace/sheets/api/samples/sheet)---Recipes that show how to create, clear, copy, and delete sheets, and also control their properties."]]