Class SpreadsheetApp

SpreadsheetApp

Google Sheets फ़ाइलें ऐक्सेस करें और बनाएं. यह स्प्रेडशीट सेवा की पैरंट क्लास है.

प्रॉपर्टी

प्रॉपर्टीटाइपब्यौरा
AutoFillSeriesAutoFillSeriesअपने-आप भरी जाने वाली वैल्यू को कैलकुलेट करने के लिए, इस्तेमाल की जाने वाली सीरीज़ के टाइप की गिनती.
BandingThemeBandingThemeसंभावित बैंडिंग थीम की सूची.
BooleanCriteriaBooleanCriteriaकंडिशनल फ़ॉर्मैटिंग के बूलियन मापदंड की गिनती.
BorderStyleBorderStyleRange पर बॉर्डर सेट करने के लिए मान्य स्टाइल की गिनती.
ColorTypeColorTypeसंभावित रंगों की सूची.
CopyPasteTypeCopyPasteTypeसंभावित पेस्ट टाइप की गिनती.
DataExecutionErrorCodeDataExecutionErrorCodeडेटा प्रोसेस करने में होने वाली संभावित गड़बड़ी के कोड की गिनती.
DataExecutionStateDataExecutionStateडेटा प्रोसेस किए जाने की संभावित स्थितियों की गिनती.
DataSourceParameterTypeDataSourceParameterTypeसंभावित डेटा सोर्स पैरामीटर टाइप की गिनती.
DataSourceRefreshScopeDataSourceRefreshScopeडेटा सोर्स के रीफ़्रेश होने के संभावित स्कोप की सूची.
DataSourceTypeDataSourceTypeसंभावित डेटा सोर्स टाइप की गिनती.
DataValidationCriteriaDataValidationCriteriaडेटा की पुष्टि करने की उस शर्त को दिखाने वाली गिनती, जिसे किसी रेंज पर सेट किया जा सकता है.
DateTimeGroupingRuleTypeDateTimeGroupingRuleTypeतारीख और समय के हिसाब से ग्रुप में रखने के नियम की गिनती.
DeveloperMetadataLocationTypeDeveloperMetadataLocationTypeसंभावित डेवलपर मेटाडेटा की जगह के टाइप की सूची.
DeveloperMetadataVisibilityDeveloperMetadataVisibilityसंभावित डेवलपर मेटाडेटा दिखाई देने वालों की सूची.
DimensionDimensionस्प्रेडशीट के संभावित डाइमेंशन की गिनती.
DirectionDirectionउन संभावित दिशा-निर्देशों की गिनती जिन्हें ऐरो का इस्तेमाल करके स्प्रेडशीट में इधर-उधर ले जाया जा सकता है बटन का इस्तेमाल करें.
FrequencyTypeFrequencyTypeसंभावित फ़्रीक्वेंसी टाइप की गिनती.
GroupControlTogglePositionGroupControlTogglePositionउन पोज़िशन की गिनती जिनमें ग्रुप कंट्रोल करने वाला टॉगल शामिल हो सकता है.
InterpolationTypeInterpolationTypeकंडिशनल फ़ॉर्मैट के ग्रेडिएंट इंटरपोलेशन टाइप की गिनती.
PivotTableSummarizeFunctionPivotTableSummarizeFunctionपिवट टेबल में वैल्यू की खास जानकारी देने के लिए, इस्तेमाल किए जा सकने वाले फ़ंक्शन की सूची.
PivotValueDisplayTypePivotValueDisplayTypeउन तरीकों की गिनती जिनसे पिवट वैल्यू को दिखाया जा सकता है.
ProtectionTypeProtectionTypeस्प्रेडशीट के उन हिस्सों के बारे में जानकारी देने वाली गिनती जिन्हें बदलाव करने से सुरक्षित किया जा सकता है.
RecalculationIntervalRecalculationIntervalऐसे संभावित इंटरवल की गिनती जिनका इस्तेमाल स्प्रेडशीट को फिर से कैलकुलेट करने के लिए किया जा सकता है.
RelativeDateRelativeDateतारीख के हिसाब से BooleanCriteria में इस्तेमाल की जाने वाली वैल्यू को कैलकुलेट करने के लिए, मिलती-जुलती तारीख के विकल्पों की गिनती.
SheetTypeSheetTypeउन अलग-अलग तरह की शीट की गिनती जो किसी स्प्रेडशीट में हो सकती हैं.
SortOrderSortOrderक्रम से लगाने के क्रम की गिनती.
TextDirectionTextDirectionमान्य टेक्स्ट वाले निर्देशों की सूची.
TextToColumnsDelimiterTextToColumnsDelimiterटेक्स्ट को कॉलम में बांटने के लिए, प्रीसेट डीलिमिटर की गिनती.
ThemeColorTypeThemeColorTypeसंभावित थीम कलर के टाइप की सूची.
ValueTypeValueTypeस्प्रेडशीट सेवा की रेंज क्लास से, Range.getValue() और Range.getValues() के ज़रिए दिखाई गई वैल्यू टाइप की गिनती. इन्यूमरेशन वैल्यू नीचे दी गई सूची में, Number, Boolean, Date या String के अलावा अन्य विकल्प भी हैं.
WrapStrategyWrapStrategyसेल रैप करने के लिए इस्तेमाल की जाने वाली रणनीतियों की गिनती.

तरीके

तरीकारिटर्न टाइपसंक्षिप्त विवरण
create(name)Spreadsheetदिए गए नाम के साथ एक नई स्प्रेडशीट बनाता है.
create(name, rows, columns)Spreadsheetदिए गए नाम के साथ-साथ पंक्तियों और कॉलम की तय संख्या के साथ एक नई स्प्रेडशीट बनाता है.
enableAllDataSourcesExecution()voidसभी तरह के डेटा सोर्स के लिए, डेटा प्रोसेस करने की सुविधा चालू करता है.
enableBigQueryExecution()voidBigQuery डेटा सोर्स के लिए, डेटा प्रोसेस करने की सुविधा चालू करता है.
flush()voidस्प्रेडशीट में किए गए सभी रुके हुए बदलाव लागू होते हैं.
getActive()Spreadsheetमौजूदा स्प्रेडशीट को दिखाता है. अगर कोई स्प्रेडशीट नहीं है, तो null दिखाता है.
getActiveRange()Rangeऐक्टिव शीट में चुनी गई रेंज दिखाता है. अगर कोई रेंज चालू नहीं है, तो null दिखाता है.
getActiveRangeList()RangeListयह फ़ंक्शन ऐक्टिव शीट में ऐक्टिव रेंज की सूची दिखाता है. अगर कोई रेंज नहीं है, तो null चुना गया.
getActiveSheet()Sheetएक्टिव शीट को स्प्रेडशीट में लाता है.
getActiveSpreadsheet()Spreadsheetमौजूदा स्प्रेडशीट को दिखाता है. अगर कोई स्प्रेडशीट नहीं है, तो null दिखाता है.
getCurrentCell()Rangeवह मौजूदा (हाइलाइट किया गया) सेल लौटाता है जिसे ऐक्टिव शीट या अगर कोई मौजूदा सेल न हो, तो null.
getSelection()Selectionयह स्प्रेडशीट में मौजूदा Selection दिखाता है.
getUi()Uiयह स्प्रेडशीट के यूज़र इंटरफ़ेस एनवायरमेंट का इंस्टेंस दिखाता है, ताकि स्क्रिप्ट मेन्यू, डायलॉग, और साइडबार जैसी सुविधाएं जोड़ें.
newCellImage()CellImageBuilderCellImage के लिए बिल्डर बनाता है.
newColor()ColorBuilderColor के लिए बिल्डर बनाता है.
newConditionalFormatRule()ConditionalFormatRuleBuilderकंडिशनल फ़ॉर्मैटिंग के नियम के लिए बिल्डर बनाता है.
newDataSourceSpec()DataSourceSpecBuilderDataSourceSpec के लिए बिल्डर बनाता है.
newDataValidation()DataValidationBuilderडेटा की पुष्टि के नियम के लिए बिल्डर बनाता है.
newFilterCriteria()FilterCriteriaBuilderFilterCriteria के लिए बिल्डर बनाता है.
newRichTextValue()RichTextValueBuilderरिच टेक्स्ट की वैल्यू के लिए बिल्डर बनाता है.
newTextStyle()TextStyleBuilderटेक्स्ट की स्टाइल के लिए बिल्डर बनाता है.
open(file)Spreadsheetदिए गए फ़ाइल ऑब्जेक्ट से जुड़ी स्प्रेडशीट खोलता है.
openById(id)Spreadsheetदिए गए आईडी के साथ स्प्रेडशीट खोलता है.
openByUrl(url)Spreadsheetदिए गए यूआरएल के साथ स्प्रेडशीट खोलता है.
setActiveRange(range)Rangeसबसे ऊपर वाली रेंज में, बताई गई रेंज को active range के तौर पर सेट करता है current cell के रूप में श्रेणी में बायां सेल.
setActiveRangeList(rangeList)RangeListरेंज की बताई गई सूची को active ranges के तौर पर सेट करता है.
setActiveSheet(sheet)Sheetकिसी स्प्रेडशीट में ऐक्टिव शीट को सेट करता है.
setActiveSheet(sheet, restoreSelection)Sheetयह विकल्प किसी स्प्रेडशीट में ऐक्टिव शीट सेट करता है. साथ ही, इसमें सबसे हाल ही में चुनी गई शीट को वापस लाने का विकल्प भी होता है डालें.
setActiveSpreadsheet(newActiveSpreadsheet)voidचालू स्प्रेडशीट को सेट करता है.
setCurrentCell(cell)Rangeचुने गए सेल को current cell के रूप में सेट करता है.

विस्तृत दस्तावेज़

create(name)

दिए गए नाम के साथ एक नई स्प्रेडशीट बनाता है.

// The code below creates a new spreadsheet "Finances" and logs the URL for it
var ssNew = SpreadsheetApp.create("Finances");
Logger.log(ssNew.getUrl());

पैरामीटर

नामटाइपब्यौरा
nameStringस्प्रेडशीट का नाम.

वापसी का टिकट

Spreadsheet — एक नई स्प्रेडशीट

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets

create(name, rows, columns)

दिए गए नाम के साथ-साथ पंक्तियों और कॉलम की तय संख्या के साथ एक नई स्प्रेडशीट बनाता है.

// The code below creates a new spreadsheet "Finances" with 50 rows and 5 columns and logs the
// URL for it
var ssNew = SpreadsheetApp.create("Finances", 50, 5);
Logger.log(ssNew.getUrl());

पैरामीटर

नामटाइपब्यौरा
nameStringस्प्रेडशीट का नाम.
rowsIntegerस्प्रेडशीट के लिए पंक्तियों की संख्या.
columnsIntegerस्प्रेडशीट के लिए कॉलम की संख्या.

वापसी का टिकट

Spreadsheet — एक नई स्प्रेडशीट

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets

enableAllDataSourcesExecution()

सभी तरह के डेटा सोर्स के लिए, डेटा प्रोसेस करने की सुविधा चालू करता है.

अगर डेटा सोर्स का टाइप चालू नहीं है, तो डेटा प्रोसेस होने की वजह से अपवाद हो सकता है. इस तरीके का इस्तेमाल करें सभी तरह के डेटा सोर्स का डेटा प्रोसेस करने की सुविधा चालू की जा सकती है.

// Turns data execution on for all types of data sources.
SpreadsheetApp.enableAllDataSourcesExecution();

// 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 the first data source sheet in the spreadsheet and refreshes the data.
ss.getDataSourceSheets()[0].refreshData();

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/bigquery.readonly

enableBigQueryExecution()

BigQuery डेटा सोर्स के लिए, डेटा प्रोसेस करने की सुविधा चालू करता है.

अगर BigQuery डेटा सोर्स का डेटा प्रोसेस नहीं किया जाता है, तो इसका डेटा प्रोसेस नहीं किया जा सकता.

// Turns data execution on for BigQuery data sources.
SpreadsheetApp.enableBigQueryExecution();

// 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 the first data source sheet in the spreadsheet and refreshes the BigQuery data.
ss.getDataSourceSheets()[0].refreshData();

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/bigquery.readonly

flush()

स्प्रेडशीट में किए गए सभी रुके हुए बदलाव लागू होते हैं.

स्प्रेडशीट की कार्रवाइयों को कभी-कभी एक साथ बंडल किया जाता है, ताकि परफ़ॉर्मेंस बेहतर हो सके. उदाहरण के लिए, जब Range.getValue() को कई कॉल करके. हालाँकि, कभी-कभी हो सकता है कि आप यह सुनिश्चित करना चाहें कि बाद में किए जाने वाले बदलाव तुरंत लागू कर दिए जाते हैं. उदाहरण के लिए, स्क्रिप्ट के चलते हुए उपयोगकर्ताओं का डेटा दिखाना.

// The code below changes the background color of cells A1 and B1 twenty times. You should be
// able to see the updates live in the spreadsheet. If flush() is not called, the updates may
// be applied live or may all be applied at once when the script completes.
function colors() {
  var sheet = SpreadsheetApp.getActiveSheet();
  for (var i = 0; i < 20; i++) {
    if ((i % 2) == 0) {
      sheet.getRange('A1').setBackground('green');
      sheet.getRange('B1').setBackground('red');
    } else {
      sheet.getRange('A1').setBackground('red');
      sheet.getRange('B1').setBackground('green');
    }
    SpreadsheetApp.flush();
  }
}

getActive()

मौजूदा स्प्रेडशीट को दिखाता है. अगर कोई स्प्रेडशीट नहीं है, तो null दिखाता है.

स्प्रेडशीट के कॉन्टेक्स्ट में चलने वाले फ़ंक्शन को इस फ़ंक्शन को कॉल करके संबंधित स्प्रेडशीट ऑब्जेक्ट को कॉल करें.

// The code below logs the URL for the active spreadsheet.
Logger.log(SpreadsheetApp.getActive().getUrl());

वापसी का टिकट

Spreadsheet — सक्रिय स्प्रेडशीट ऑब्जेक्ट

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getActiveRange()

ऐक्टिव शीट में चुनी गई रेंज दिखाता है. अगर कोई रेंज चालू नहीं है, तो null दिखाता है. अगर आपने एक से ज़्यादा रेंज को चुनने पर, यह तरीका सिर्फ़ चुनी गई आखिरी रेंज दिखाता है.

आम तौर पर, इसका मतलब वह रेंज होती है जिसे उपयोगकर्ता ने ऐक्टिव शीट में चुना है. हालांकि, कस्टम फ़ंक्शन को सक्रिय रूप से फिर से गणना की जा रही सेल को कहा जाता है.

// The code below logs the background color for the active range.
var colorObject = SpreadsheetApp.getActiveRange().getBackgroundObject();
// Assume the color has ColorType.RGB.
Logger.log(colorObject.asRgbColor().asHexString());

वापसी का टिकट

Range — ऐक्टिव रेंज.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getActiveRangeList()

यह फ़ंक्शन ऐक्टिव शीट में ऐक्टिव रेंज की सूची दिखाता है. अगर कोई रेंज नहीं है, तो null चुना गया. हाइलाइट की गई मौजूदा सेल वाली ऐक्टिव रेंज को सूची में सबसे आखिर में रखा जाता है.

अगर सिर्फ़ एक रेंज चुनी गई है, तो यह getActiveRange() कॉल की तरह काम करती है.

// Returns the list of active ranges.
var rangeList = SpreadsheetApp.getActiveRangeList();

वापसी का टिकट

RangeList — चालू रेंज की सूची

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getActiveSheet()

एक्टिव शीट को स्प्रेडशीट में लाता है.

किसी स्प्रेडशीट में मौजूद ऐक्टिव शीट, वह शीट है जो स्प्रेडशीट में दिखाई जा रही है यूज़र इंटरफ़ेस (यूआई).

// The code below logs the name of the active sheet.
Logger.log(SpreadsheetApp.getActiveSheet().getName());

वापसी का टिकट

Sheet — सक्रिय शीट ऑब्जेक्ट

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getActiveSpreadsheet()

मौजूदा स्प्रेडशीट को दिखाता है. अगर कोई स्प्रेडशीट नहीं है, तो null दिखाता है.

स्प्रेडशीट के कॉन्टेक्स्ट में चलने वाले फ़ंक्शन को संबंधित Spreadsheet ऑब्जेक्ट को कॉल करके इस फ़ंक्शन को कॉल करें.

// The code below logs the URL for the active spreadsheet.
Logger.log(SpreadsheetApp.getActiveSpreadsheet().getUrl());

वापसी का टिकट

Spreadsheet — सक्रिय स्प्रेडशीट ऑब्जेक्ट

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getCurrentCell()

वह मौजूदा (हाइलाइट किया गया) सेल लौटाता है जिसे ऐक्टिव शीट या अगर कोई मौजूदा सेल न हो, तो null.

// Returns the current highlighted cell in the one of the active ranges.
var currentCell = SpreadsheetApp.getCurrentCell();

वापसी का टिकट

Range — मौजूदा सेल

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getSelection()

यह स्प्रेडशीट में मौजूदा Selection दिखाता है.

var selection = SpreadsheetApp.getSelection();
var currentCell = selection.getCurrentCell();

वापसी का टिकट

Selection — फ़िलहाल चुना गया

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getUi()

यह स्प्रेडशीट के यूज़र इंटरफ़ेस एनवायरमेंट का इंस्टेंस दिखाता है, ताकि स्क्रिप्ट मेन्यू, डायलॉग, और साइडबार जैसी सुविधाएं जोड़ें. स्क्रिप्ट स्प्रेडशीट में बाधित होने पर ही स्क्रिप्ट का इस्तेमाल किया जा सकता है. ज़्यादा जानकारी के लिए, यह देखें मेन्यू, डायलॉग, और साइडबार की गाइड.

// Add a custom menu to the active spreadsheet, including a separator and a sub-menu.
function onOpen(e) {
  SpreadsheetApp.getUi()
      .createMenu('My Menu')
      .addItem('My menu item', 'myFunction')
      .addSeparator()
      .addSubMenu(SpreadsheetApp.getUi().createMenu('My sub-menu')
          .addItem('One sub-menu item', 'mySecondFunction')
          .addItem('Another sub-menu item', 'myThirdFunction'))
      .addToUi();
}

वापसी का टिकट

Ui — इस स्प्रेडशीट के यूज़र इंटरफ़ेस एनवायरमेंट का इंस्टेंस


newCellImage()

CellImage के लिए बिल्डर बनाता है.

// 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 on Sheet1.
const range = sheet.getRange('A1');

// Builds an image using a source URL.
const cellImage = SpreadsheetApp.newCellImage()
  .setSourceUrl('https://www.gstatic.com/images/branding/productlogos/apps_script/v10/web-64dp/logo_apps_script_color_1x_web_64dp.png')
  .build();

// Sets the image in cell A1.
range.setValue(cellImage);

वापसी का टिकट

CellImageBuilder — नया बिल्डर.


newColor()

Color के लिए बिल्डर बनाता है.

var rgbColor = SpreadsheetApp.newColor().setRgbColor("#FF0000").build();

वापसी का टिकट

ColorBuilder — नया बिल्डर.


newConditionalFormatRule()

कंडिशनल फ़ॉर्मैटिंग के नियम के लिए बिल्डर बनाता है.

// Adds a conditional format rule to a sheet that causes all cells in range A1:B3 to turn red
// if they contain a number between 1 and 10.
var sheet = SpreadsheetApp.getActive().getActiveSheet();
var range = sheet.getRange('A1:B3');
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberBetween(1, 10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build()
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

वापसी का टिकट

ConditionalFormatRuleBuilder — नया बिल्डर.


newDataSourceSpec()

DataSourceSpec के लिए बिल्डर बनाता है.

// 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');

// Enables BigQuery.
SpreadsheetApp.enableBigQueryExecution();

// Builds a data source specification.
// TODO (developer): Update the project ID to your own Google Cloud project ID.
const dataSourceSpec = SpreadsheetApp.newDataSourceSpec()
  .asBigQuery()
  .setProjectId('project-id-1')
  .setTableProjectId('bigquery-public-data')
  .setDatasetId('ncaa_basketball')
  .setTableId('mbb_historical_teams_games')
  .build();

// Adds the data source and its data to the spreadsheet.
ss.insertDataSourceSheet(dataSourceSpec);

वापसी का टिकट

DataSourceSpecBuilder — नया बिल्डर.


newDataValidation()

डेटा की पुष्टि के नियम के लिए बिल्डर बनाता है.

var cell = SpreadsheetApp.getActive().getRange('A1');
var rule = SpreadsheetApp.newDataValidation()
    .requireNumberBetween(1, 100)
    .setAllowInvalid(false)
    .setHelpText('Number must be between 1 and 100.')
    .build();
cell.setDataValidation(rule);

वापसी का टिकट

DataValidationBuilder — नया बिल्डर.


newFilterCriteria()

FilterCriteria के लिए बिल्डर बनाता है.

// 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 the range to A1:D20.
const range = sheet.getRange('A1:D20');

// Creates a filter and applies it to the specified range.
range.createFilter();

// Gets the current filter for the range and creates filter criteria that only shows cells
// that aren't empty.
const filter = range.getFilter();
const criteria = SpreadsheetApp.newFilterCriteria().whenCellNotEmpty().build();

// Sets the criteria to  column C.
filter.setColumnFilterCriteria(3, criteria);

वापसी का टिकट

FilterCriteriaBuilder — नया बिल्डर


newRichTextValue()

रिच टेक्स्ट की वैल्यू के लिए बिल्डर बनाता है.

// Sets cell A1 to have the text "Hello world", with "Hello" bolded.
var cell = SpreadsheetApp.getActive().getRange('A1');
var bold = SpreadsheetApp.newTextStyle().setBold(true).build();
var value = SpreadsheetApp.newRichTextValue()
    .setText("Hello world")
    .setTextStyle(0, 5, bold)
    .build();
cell.setRichTextValue(value);

वापसी का टिकट

RichTextValueBuilder — नया बिल्डर.


newTextStyle()

टेक्स्ट की स्टाइल के लिए बिल्डर बनाता है.

// Sets range A1:B3 to have red, size 22, bolded, underlined text.
var range = SpreadsheetApp.getActive().getRange('A1:B3');
var style = SpreadsheetApp.newTextStyle()
    .setForegroundColor("red")
    .setFontSize(22)
    .setBold(true)
    .setUnderline(true)
    .build();
range.setTextStyle(style);

वापसी का टिकट

TextStyleBuilder — नया बिल्डर.


open(file)

दिए गए फ़ाइल ऑब्जेक्ट से जुड़ी स्प्रेडशीट खोलता है.

// Get any starred spreadsheets from Google Drive, then open the spreadsheets and log the name
// of the first sheet within each spreadsheet.
var files = DriveApp.searchFiles(
    'starred = true and mimeType = "' + MimeType.GOOGLE_SHEETS + '"');
while (files.hasNext()) {
  var spreadsheet = SpreadsheetApp.open(files.next());
  var sheet = spreadsheet.getSheets()[0];
  Logger.log(sheet.getName());
}

पैरामीटर

नामटाइपब्यौरा
fileFileखोली जाने वाली फ़ाइल.

वापसी का टिकट

Spreadsheet — स्प्रेडशीट

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets

openById(id)

दिए गए आईडी के साथ स्प्रेडशीट खोलता है. स्प्रेडशीट आईडी को उसके यूआरएल से निकाला जा सकता है. इसके लिए उदाहरण के लिए, यूआरएल https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 में स्प्रेडशीट आईडी "abc1234567" है.

// The code below opens a spreadsheet using its ID and logs the name for it.
// Note that the spreadsheet is NOT physically opened on the client side.
// It is opened on the server only (for modification by the script).
var ss = SpreadsheetApp.openById("abc1234567");
Logger.log(ss.getName());

पैरामीटर

नामटाइपब्यौरा
idStringस्प्रेडशीट के लिए यूनीक आइडेंटिफ़ायर.

वापसी का टिकट

Spreadsheet — दिए गए आईडी के साथ स्प्रेडशीट ऑब्जेक्ट

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets

openByUrl(url)

दिए गए यूआरएल के साथ स्प्रेडशीट खोलता है. URL मौजूद न होने पर स्क्रिप्टिंग अपवाद देता है या उपयोगकर्ता के पास इसे ऐक्सेस करने की अनुमति नहीं है.

// Opens a spreadsheet by its URL and logs its name.
// Note that the spreadsheet doesn't physically open on the client side.
// It opens on the server only (for modification by the script).
var ss = SpreadsheetApp.openByUrl(
    'https://docs.google.com/spreadsheets/d/abc1234567/edit');
console.log(ss.getName());

पैरामीटर

नामटाइपब्यौरा
urlStringस्प्रेडशीट के लिए यूआरएल.

वापसी का टिकट

Spreadsheet — दिए गए यूआरएल के साथ स्प्रेडशीट ऑब्जेक्ट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets

setActiveRange(range)

सबसे ऊपर वाली रेंज में, बताई गई रेंज को active range के तौर पर सेट करता है current cell के रूप में श्रेणी में बायां सेल.

स्प्रेडशीट का यूज़र इंटरफ़ेस (यूआई), वह शीट दिखाता है जिसमें चुनी गई रेंज शामिल है. साथ ही, इसमें सेल भी चुनी गई हैं चुनी गई रेंज में तय किया गया है.

// The code below sets range C1:D4 in the first sheet as the active range.
var range = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getRange('C1:D4');
SpreadsheetApp.setActiveRange(range);

var selection = SpreadsheetApp.getSelection();
// Current cell: C1
var currentCell = selection.getCurrentCell();
// Active Range: C1:D4
var activeRange = selection.getActiveRange();

पैरामीटर

नामटाइपब्यौरा
rangeRangeवह रेंज जिसे ऐक्टिव रेंज में शामिल किया जाना है.

वापसी का टिकट

Range — नई चालू रेंज


setActiveRangeList(rangeList)

रेंज की बताई गई सूची को active ranges के तौर पर सेट करता है. आखिरी सूची में मौजूद रेंज को active range के तौर पर सेट किया गया है.

// The code below sets ranges [D4, B2:C4] in the active sheet as the active ranges.
var rangeList = SpreadsheetApp.getActiveSheet().getRanges(['D4', 'B2:C4']);
SpreadsheetApp.setActiveRangeList(rangeList);

var selection = SpreadsheetApp.getSelection();
// Current cell: B2
var currentCell = selection.getCurrentCell();
// Active range: B2:C4
var activeRange = selection.getActiveRange();
// Active range list: [D4, B2:C4]
var activeRangeList = selection.getActiveRangeList();

पैरामीटर

नामटाइपब्यौरा
rangeListRangeListचुनने के लिए रेंज की सूची.

वापसी का टिकट

RangeList — रेंज की नई चुनी गई सूची

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setActiveSheet(sheet)

किसी स्प्रेडशीट में ऐक्टिव शीट को सेट करता है. Google Sheets का यूज़र इंटरफ़ेस (यूआई), चुनी गई शीट को तब तक दिखाता है, जब तक कि यह शीट किसी दूसरी स्प्रेडशीट से जुड़ी है.

// The code below makes the 2nd sheet active in the active spreadsheet.
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
SpreadsheetApp.setActiveSheet(spreadsheet.getSheets()[1]);

पैरामीटर

नामटाइपब्यौरा
sheetSheetनई ऐक्टिव शीट.

वापसी का टिकट

Sheet — वह शीट जिसे नई सक्रिय शीट बना दी गई है


setActiveSheet(sheet, restoreSelection)

सबसे हाल ही में चुनी गई शीट को वापस लाने के विकल्प के साथ, यह स्प्रेडशीट में ऐक्टिव शीट को सेट करता है डालें. Google Sheets का यूज़र इंटरफ़ेस (यूआई), चुनी गई शीट को तब तक दिखाता है, जब तक कि वह शीट किसी अलग-अलग स्प्रेडशीट बनाई हैं.

var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var firstSheet = spreadsheet.getSheets()[0];
var secondSheet = spreadsheet.getSheets()[1];
// Set the first sheet as the active sheet and select the range D4:F4.
spreadsheet.setActiveSheet(firstSheet).getRange('D4:F4').activate();

// Switch to the second sheet to do some work.
spreadsheet.setActiveSheet(secondSheet);
// Switch back to first sheet, and restore its selection.
spreadsheet.setActiveSheet(firstSheet, true);

// The selection of first sheet is restored, and it logs D4:F4
var range = spreadsheet.getActiveSheet().getSelection().getActiveRange();
Logger.log(range.getA1Notation());

पैरामीटर

नामटाइपब्यौरा
sheetSheetनई ऐक्टिव शीट.
restoreSelectionBooleanअगर true, नई ऐक्टिव शीट के सबसे हाल के चुने गए नई शीट के चालू होते ही फिर से चुन लिया जाता है; अगर false, नई शीट मौजूदा विकल्प को बदले बिना चालू हो जाता है.

वापसी का टिकट

Sheet — नई ऐक्टिव शीट

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setActiveSpreadsheet(newActiveSpreadsheet)

चालू स्प्रेडशीट को सेट करता है.

// The code below makes the spreadsheet with key "1234567890" the active spreadsheet
var ss = SpreadsheetApp.openById("1234567890");
SpreadsheetApp.setActiveSpreadsheet(ss);

पैरामीटर

नामटाइपब्यौरा
newActiveSpreadsheetSpreadsheetसक्रिय स्प्रैडशीट बनाई जाने वाली स्प्रैडशीट.

setCurrentCell(cell)

चुने गए सेल को current cell के रूप में सेट करता है.

अगर वह सेल पहले से चुनी गई रेंज में मौजूद है, तो वह रेंज मौजूदा सेल के तौर पर सेल के साथ ऐक्टिव रेंज.

अगर चुना गया सेल किसी भी चुनी गई रेंज में मौजूद नहीं है, तो मौजूदा चुनाव यह होता है हटा दिया जाता है और सेल, मौजूदा सेल और ऐक्टिव रेंज बन जाता है.

ध्यान दें: बताए गए Range में एक सेल होना चाहिए, नहीं तो यह तरीका एक अपवाद देता है.

// The code below sets the cell B5 in the first sheet as the current cell.
var cell = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getRange('B5');
SpreadsheetApp.setCurrentCell(cell);

var selection = SpreadsheetApp.getSelection();
// Current cell: B5
var currentCell = selection.getCurrentCell();

पैरामीटर

नामटाइपब्यौरा
cellRangeवर्तमान सेल के रूप में सेट किया जाने वाला सेल.

वापसी का टिकट

Range — नया सेट किया गया मौजूदा सेल

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets