Google E-Tablolar dosyalarına erişebilir ve bu dosyaları oluşturabilirsiniz. Bu sınıf, Spreadsheet hizmetinin üst sınıfıdır.
Özellikler
| Mülk | Tür | Açıklama |
|---|---|---|
Auto | Auto | Otomatik doldurulmuş değerleri hesaplamak için kullanılan seri türlerinin numaralandırılması. |
Banding | Banding | Olası bant temalarının numaralandırılması. |
Boolean | Boolean | Koşullu biçimlendirme boole ölçütlerinin numaralandırılması. |
Border | Border | Range üzerinde kenarlık ayarlamak için geçerli stillerin numaralandırılması. |
Color | Color | Olası renk türlerinin numaralandırılması. |
Copy | Copy | Olası yapıştırma türlerinin numaralandırılması. |
Data | Data | Olası veri yürütme hata kodlarının numaralandırılması. |
Data | Data | Olası veri yürütme durumlarının numaralandırılması. |
Data | Data | Olası veri kaynağı parametre türlerinin numaralandırılması. |
Data | Data | Olası veri kaynağı yenileme kapsamlarının numaralandırılması. |
Data | Data | Olası veri kaynağı türlerinin numaralandırılması. |
Data | Data | Bir aralıkta ayarlanabilecek veri doğrulama ölçütlerini temsil eden bir numaralandırma. |
Date | Date | Tarih saat gruplandırma kuralının numaralandırılması. |
Developer | Developer | Olası geliştirici meta verisi konum türlerinin numaralandırılması. |
Developer | Developer | Olası geliştirici meta verisi görünürlüklerinin numaralandırılması. |
Dimension | Dimension | Bir e-tablonun olası boyutlarının numaralandırılması. |
Direction | Direction | Ok tuşlarını kullanarak bir e-tabloda hareket etmenin olası yönlerinin listesi. |
Frequency | Frequency | Olası sıklık türlerinin numaralandırılması. |
Group | Group | Grup kontrolü açma/kapatma düğmesinin bulunabileceği konumların listesi. |
Interpolation | Interpolation | Koşullu biçim gradyanı enterpolasyon türlerinin numaralandırılması. |
Pivot | Pivot | Pivot tablodaki değerleri özetlemek için kullanılabilecek işlevlerin numaralandırılması. |
Pivot | Pivot | Bir pivot değerinin gösterilebileceği yöntemlerin numaralandırılması. |
Protection | Protection | Bir e-tablonun düzenlemelere karşı korunabilecek kısımlarını temsil eden bir numaralandırma. |
Recalculation | Recalculation | E-tablo yeniden hesaplamasında kullanılabilecek olası aralıkların numaralandırılması. |
Relative | Relative | Tarihe dayalı Boolean içinde kullanılacak bir değeri hesaplamak için göreli tarih seçeneklerinin numaralandırılması. |
Sheet | Sheet | Bir e-tabloda bulunabilecek farklı sayfa türlerinin numaralandırılması. |
Sort | Sort | Sıralama düzeninin numaralandırılması. |
Text | Text | Geçerli metin yönlendirmelerinin listesi. |
Text | Text | Metni sütunlara bölmek için önceden ayarlanmış sınırlayıcıların numaralandırılmış listesi. |
Theme | Theme | Olası tema rengi türlerinin numaralandırılması. |
Value | Value | E-tablo hizmetinin Range sınıfındaki Range.getValue() ve Range.getValues() tarafından döndürülen değer türlerinin numaralandırılması. Aşağıda listelenen numaralandırma değerleri Number, Boolean, Date veya String'e ek olarak kullanılır. |
Wrap | Wrap | Hücreleri sarmak için kullanılan stratejilerin numaralandırılması. |
Yöntemler
| Yöntem | Dönüş türü | Kısa açıklama |
|---|---|---|
create(name) | Spreadsheet | Belirtilen ada sahip yeni bir e-tablo oluşturur. |
create(name, rows, columns) | Spreadsheet | Belirtilen adla ve belirtilen sayıda satır ve sütunla yeni bir e-tablo oluşturur. |
enable | void | Tüm veri kaynağı türleri için veri yürütmeyi etkinleştirir. |
enable | void | BigQuery veri kaynakları için veri yürütmeyi etkinleştirir. |
enable | void | Looker veri kaynakları için veri yürütmeyi etkinleştirir. |
flush() | void | Beklemede olan tüm e-tablo değişikliklerini uygular. |
get | Spreadsheet | Şu anda etkin olan e-tabloyu veya etkin e-tablo yoksa null değerini döndürür. |
get | Range | Etkin sayfadaki seçili aralığı veya etkin bir aralık yoksa null değerini döndürür. |
get | Range | Etkin sayfadaki etkin aralıkların listesini veya aralık seçilmemişse null değerini döndürür. |
get | Sheet | Bir e-tablodaki etkin sayfayı alır. |
get | Spreadsheet | Şu anda etkin olan e-tabloyu veya etkin e-tablo yoksa null değerini döndürür. |
get | Range|null | Etkin sayfadaki etkin aralıklardan birinde seçilen geçerli (vurgulanmış) hücreyi veya geçerli hücre yoksa null değerini döndürür. |
get | Selection | E-tablodaki geçerli Selection değerini döndürür. |
get | Ui | E-tablonun kullanıcı arayüzü ortamının bir örneğini döndürür. Bu örnek, komut dosyasının menüler, iletişim kutuları ve kenar çubukları gibi özellikler eklemesine olanak tanır. |
new | Cell | Cell için bir derleyici oluşturur. |
new | Color | Color için bir derleyici oluşturur. |
new | Conditional | Koşullu biçimlendirme kuralı için oluşturucu oluşturur. |
new | Data | Data için bir derleyici oluşturur. |
new | Data | Veri doğrulama kuralı için oluşturucu oluşturur. |
new | Filter | Filter için bir derleyici oluşturur. |
new | Rich | Zengin metin değeri için bir oluşturucu oluşturur. |
new | Text | Metin stili için oluşturucu oluşturur. |
open(file) | Spreadsheet | Belirtilen File nesnesine karşılık gelen e-tabloyu açar. |
open | Spreadsheet | Belirtilen kimliğe sahip e-tabloyu açar. |
open | Spreadsheet | Belirtilen URL'ye sahip e-tabloyu açar. |
set | Range | Belirtilen aralığı active range olarak ayarlar. Aralıktaki sol üst hücre current cell olur. |
set | Range | Belirtilen aralık listesini active ranges olarak ayarlar. |
set | Sheet | Bir e-tabloda etkin sayfayı ayarlar. |
set | Sheet | Bir e-tabloda etkin sayfayı ayarlar. Bu sayfada en son seçimi geri yükleme seçeneği de sunulur. |
set | void | Etkin e-tabloyu ayarlar. |
set | Range | Belirtilen hücreyi current cell olarak ayarlar. |
Ayrıntılı belgeler
create(name)
Belirtilen ada sahip yeni bir e-tablo oluşturur.
// The code below creates a new spreadsheet "Finances" and logs the URL for it const ssNew = SpreadsheetApp.create('Finances'); Logger.log(ssNew.getUrl());
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
name | String | E-tablonun adı. |
Return
Spreadsheet: Yeni bir e-tablo
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets
create(name, rows, columns)
Belirtilen adla ve belirtilen sayıda satır ve sütunla yeni bir e-tablo oluşturur.
// The code below creates a new spreadsheet "Finances" with 50 rows and 5 // columns and logs the URL for it const ssNew = SpreadsheetApp.create('Finances', 50, 5); Logger.log(ssNew.getUrl());
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
name | String | E-tablonun adı. |
rows | Integer | E-tablonun satır sayısı. |
columns | Integer | E-tablonun sütun sayısı. |
Return
Spreadsheet: Yeni bir e-tablo
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets
enable All Data Sources Execution()
Tüm veri kaynağı türleri için veri yürütmeyi etkinleştirir.
Veri kaynağı türü etkinleştirilmemişse veri yürütme işlemi istisna oluşturur. Tüm veri kaynağı türleri için veri yürütmeyi etkinleştirmek üzere bu yöntemi kullanın.
// 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();
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/bigquery.readonly
enable Big Query Execution()
BigQuery veri kaynakları için veri yürütmeyi etkinleştirir.
BigQuery veri kaynağı için veri yürütme, etkinleştirilmediyse istisna oluşturur.
// 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();
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/bigquery.readonly
enable Looker Execution()
Looker veri kaynakları için veri yürütmeyi etkinleştirir.
Looker veri kaynağı için veri yürütme etkinleştirilmediyse istisna oluşturur.
// Turns data execution on for Looker data sources. SpreadsheetApp.enableLookerExecution(); // 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 // associated Looker data. ss.getDataSourceSheets()[0].refreshData();
flush()
Beklemede olan tüm e-tablo değişikliklerini uygular.
E-tablo işlemleri bazen performansı artırmak için birlikte gruplandırılır. Örneğin, Range.getValue() için birden fazla çağrı yapıldığında bu durum geçerlidir. Ancak bazen, örneğin bir komut dosyası yürütülürken kullanıcılara verileri göstermek için bekleyen tüm değişikliklerin hemen yapılmasını sağlamak isteyebilirsiniz.
// 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() { const sheet = SpreadsheetApp.getActiveSheet(); for (let 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(); } }
get Active()
Şu anda etkin olan e-tabloyu veya etkin e-tablo yoksa null değerini döndürür.
Bir e-tablo bağlamında çalıştırılan işlevler, bu işlevi çağırarak ilgili E-tablo nesnesine referans alabilir.
// The code below logs the URL for the active spreadsheet. Logger.log(SpreadsheetApp.getActive().getUrl());
Return
Spreadsheet: Etkin e-tablo nesnesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Active Range()
Etkin sayfadaki seçili aralığı veya etkin bir aralık yoksa null değerini döndürür. Birden fazla aralık seçilirse bu yöntem yalnızca son seçilen aralığı döndürür.
Bu genellikle kullanıcının etkin sayfada seçtiği aralık anlamına gelir ancak özel bir fonksiyonda etkin olarak yeniden hesaplanan hücreyi ifade eder.
// The code below logs the background color for the active range. const colorObject = SpreadsheetApp.getActiveRange().getBackgroundObject(); // Assume the color has ColorType.RGB. Logger.log(colorObject.asRgbColor().asHexString());
Return
Range: Etkin aralık.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Active Range List()
Etkin sayfadaki etkin aralıkların listesini veya aralık seçilmemişse null değerini döndürür. Mevcut vurgulanmış hücreyi içeren etkin aralık, listede en sona yerleştirilir.
Tek bir aralık seçiliyse bu, get çağrısı gibi davranır.
// Returns the list of active ranges. const rangeList = SpreadsheetApp.getActiveRangeList();
Return
Range: Etkin aralıkların listesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Active Sheet()
Bir e-tablodaki etkin sayfayı alır.
E-tablodaki etkin sayfa, e-tablo kullanıcı arayüzünde görüntülenen sayfadır.
// The code below logs the name of the active sheet. Logger.log(SpreadsheetApp.getActiveSheet().getName());
Return
Sheet: Etkin sayfa nesnesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Active Spreadsheet()
Şu anda etkin olan e-tabloyu veya etkin e-tablo yoksa null değerini döndürür.
Bir e-tablo bağlamında çalıştırılan işlevler, bu işlevi çağırarak ilgili Spreadsheet nesnesine referans alabilir.
// The code below logs the URL for the active spreadsheet. Logger.log(SpreadsheetApp.getActiveSpreadsheet().getUrl());
Return
Spreadsheet: Etkin e-tablo nesnesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Current Cell()
Etkin sayfadaki etkin aralıklardan birinde seçilen geçerli (vurgulanmış) hücreyi veya geçerli hücre yoksa null değerini döndürür.
// Returns the current highlighted cell in the one of the active ranges. const currentCell = SpreadsheetApp.getCurrentCell();
Return
Range|null: Geçerli hücre
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Selection()
E-tablodaki geçerli Selection değerini döndürür.
const selection = SpreadsheetApp.getSelection(); const currentCell = selection.getCurrentCell();
Return
Selection: Geçerli seçim
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
get Ui()
E-tablonun kullanıcı arayüzü ortamının bir örneğini döndürür. Bu örnek, komut dosyasının menüler, iletişim kutuları ve kenar çubukları gibi özellikler eklemesine olanak tanır. Bir komut dosyası yalnızca açık bir e-tablonun mevcut örneğinin kullanıcı arayüzüyle etkileşimde bulunabilir ve yalnızca komut dosyası e-tabloya bağlıysa bu etkileşim gerçekleşebilir. Daha fazla bilgi için menüler ve iletişim kutuları ve kenar çubukları ile ilgili kılavuzlara bakın.
// 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(); }
Return
Ui: Bu e-tablonun kullanıcı arayüzü ortamının bir örneği
new Cell Image()
Cell için bir derleyici oluşturur.
// 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);
Return
Cell: Yeni oluşturucu.
new Color()
Color için bir derleyici oluşturur.
const rgbColor = SpreadsheetApp.newColor().setRgbColor('#FF0000').build();
Return
Color: Yeni oluşturucu.
new Conditional Format Rule()
Koşullu biçimlendirme kuralı için oluşturucu oluşturur.
// 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. const sheet = SpreadsheetApp.getActive().getActiveSheet(); const range = sheet.getRange('A1:B3'); const rule = SpreadsheetApp.newConditionalFormatRule() .whenNumberBetween(1, 10) .setBackground('#FF0000') .setRanges([range]) .build(); const rules = sheet.getConditionalFormatRules(); rules.push(rule); sheet.setConditionalFormatRules(rules);
Return
Conditional — yeni oluşturucu.
new Data Source Spec()
Data için bir derleyici oluşturur.
// 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);
Return
Data: Yeni oluşturucu.
new Data Validation()
Veri doğrulama kuralı için oluşturucu oluşturur.
const cell = SpreadsheetApp.getActive().getRange('A1'); const rule = SpreadsheetApp.newDataValidation() .requireNumberBetween(1, 100) .setAllowInvalid(false) .setHelpText('Number must be between 1 and 100.') .build(); cell.setDataValidation(rule);
Return
Data: Yeni oluşturucu.
new Filter Criteria()
Filter için bir derleyici oluşturur.
// 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);
Return
Filter — yeni oluşturucu
new Rich Text Value()
Zengin metin değeri için bir oluşturucu oluşturur.
// Sets cell A1 to have the text "Hello world", with "Hello" bolded. const cell = SpreadsheetApp.getActive().getRange('A1'); const bold = SpreadsheetApp.newTextStyle().setBold(true).build(); const value = SpreadsheetApp.newRichTextValue() .setText('Hello world') .setTextStyle(0, 5, bold) .build(); cell.setRichTextValue(value);
Return
Rich: Yeni oluşturucu.
new Text Style()
Metin stili için oluşturucu oluşturur.
// Sets range A1:B3 to have red, size 22, bolded, underlined text. const range = SpreadsheetApp.getActive().getRange('A1:B3'); const style = SpreadsheetApp.newTextStyle() .setForegroundColor('red') .setFontSize(22) .setBold(true) .setUnderline(true) .build(); range.setTextStyle(style);
Return
Text: Yeni oluşturucu.
open(file)
Belirtilen File nesnesine karşılık gelen e-tabloyu açar.
// Get any starred spreadsheets from Google Drive, then open the spreadsheets // and log the name of the first sheet within each spreadsheet. const files = DriveApp.searchFiles( `starred = true and mimeType = "${MimeType.GOOGLE_SHEETS}"`, ); while (files.hasNext()) { const spreadsheet = SpreadsheetApp.open(files.next()); const sheet = spreadsheet.getSheets()[0]; Logger.log(sheet.getName()); }
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
file | File | Açılacak dosya. |
Return
Spreadsheet — e-tablo
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets
open By Id(id)
Belirtilen kimliğe sahip e-tabloyu açar. E-tablo kimliği, URL'sinden çıkarılabilir. Örneğin, https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 URL'sindeki e-tablo kimliği "abc1234567"dir.
// 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). const ss = SpreadsheetApp.openById('abc1234567'); Logger.log(ss.getName());
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
id | String | E-tablonun benzersiz tanımlayıcısı. |
Return
Spreadsheet: Belirtilen kimliğe sahip e-tablo nesnesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets
open By Url(url)
Belirtilen URL'ye sahip e-tabloyu açar. URL yoksa veya kullanıcının URL'ye erişme izni yoksa komut dosyası oluşturma istisnası oluşturur.
// 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). const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc1234567/edit', ); console.log(ss.getName());
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
url | String | E-tablonun URL'si. |
Return
Spreadsheet: Belirtilen URL'ye sahip e-tablo nesnesi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets
set Active Range(range)
Belirtilen aralığı active range olarak ayarlar. Aralıktaki sol üst hücre current cell olur.
E-tablo kullanıcı arayüzünde, seçilen aralığı içeren sayfa gösterilir ve seçilen aralıkta tanımlanan hücreler seçilir.
// The code below sets range C1:D4 in the first sheet as the active range. const range = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getRange('C1:D4'); SpreadsheetApp.setActiveRange(range); const selection = SpreadsheetApp.getSelection(); // Current cell: C1 const currentCell = selection.getCurrentCell(); // Active Range: C1:D4 const activeRange = selection.getActiveRange();
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
range | Range | Etkin aralık yapılacak aralık. |
Return
Range: Yeni etkin aralık
set Active Range List(rangeList)
Belirtilen aralık listesini active ranges olarak ayarlar. Listedeki son aralık active range olarak ayarlanır.
// The code below sets ranges [D4, B2:C4] in the active sheet as the active // ranges. const rangeList = SpreadsheetApp.getActiveSheet().getRanges(['D4', 'B2:C4']); SpreadsheetApp.setActiveRangeList(rangeList); const selection = SpreadsheetApp.getSelection(); // Current cell: B2 const currentCell = selection.getCurrentCell(); // Active range: B2:C4 const activeRange = selection.getActiveRange(); // Active range list: [D4, B2:C4] const activeRangeList = selection.getActiveRangeList();
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
range | Range | Seçilecek aralıkların listesi. |
Return
Range: Yeni seçilen aralık listesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Active Sheet(sheet)
Bir e-tabloda etkin sayfayı ayarlar. Sayfa farklı bir e-tabloya ait olmadığı sürece Google E-Tablolar kullanıcı arayüzünde seçilen sayfa gösterilir.
// The code below makes the 2nd sheet active in the active spreadsheet. const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); SpreadsheetApp.setActiveSheet(spreadsheet.getSheets()[1]);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
sheet | Sheet | Yeni etkin sayfa. |
Return
Sheet: Yeni etkin sayfa olarak belirlenen sayfa
set Active Sheet(sheet, restoreSelection)
Bir e-tabloda etkin sayfayı ayarlar. Bu sayfada en son seçimi geri yükleme seçeneği de sunulur. Sayfa farklı bir e-tabloya ait olmadığı sürece Google E-Tablolar kullanıcı arayüzünde seçilen sayfa gösterilir.
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); const firstSheet = spreadsheet.getSheets()[0]; const 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 const range = spreadsheet.getActiveSheet().getSelection().getActiveRange(); Logger.log(range.getA1Notation());
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
sheet | Sheet | Yeni etkin sayfa. |
restore | Boolean | true ise yeni sayfa etkin hale geldiğinde yeni etkin sayfanın en son seçimi tekrar seçilir. false ise mevcut seçim değiştirilmeden yeni sayfa etkin hale gelir. |
Return
Sheet: Yeni etkin sayfa
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets
set Active Spreadsheet(newActiveSpreadsheet)
Etkin e-tabloyu ayarlar.
// The code below makes the spreadsheet with key "1234567890" the active // spreadsheet const ss = SpreadsheetApp.openById('1234567890'); SpreadsheetApp.setActiveSpreadsheet(ss);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
new | Spreadsheet | Etkin e-tablo yapılacak e-tablo. |
set Current Cell(cell)
Belirtilen hücreyi current cell olarak ayarlar.
Belirtilen hücre, önceden seçilmiş bir aralıkta bulunuyorsa bu aralık, hücrenin geçerli hücre olduğu etkin aralık haline gelir.
Belirtilen hücre, seçili aralıkların hiçbirinde yoksa mevcut seçim kaldırılır ve hücre, geçerli hücre ile etkin aralık haline gelir.
Not: Belirtilen Range tek bir hücreden oluşmalıdır. Aksi takdirde bu yöntem istisna oluşturur.
// The code below sets the cell B5 in the first sheet as the current cell. const cell = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0].getRange('B5'); SpreadsheetApp.setCurrentCell(cell); const selection = SpreadsheetApp.getSelection(); // Current cell: B5 const currentCell = selection.getCurrentCell();
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
cell | Range | Geçerli hücre olarak ayarlanacak hücre. |
Return
Range: Yeni ayarlanan geçerli hücre
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/spreadsheets.currentonly -
https://www.googleapis.com/auth/spreadsheets