sht = gc.open_by_key(spreadsheetId)
requests = []
requests.append({
"insertDimension": {
"range": {
"sheetId": sheetId,
"dimension": "COLUMNS",
"startIndex": 2,
"endIndex": 4
},
"inheritFromBefore": True
}
})
body = {
'requests': requests
}
sht.batch_update(body)
gspread
является неплохим решением, но с появлением Sheets API v4, все стало немного проще.spreadsheetId=''
new_sheet_title=''
from googleapiclient.discovery import build
service = build('sheets', 'v4')
requests = []
requests.append({
'addSheet': {
'properties': {
'title': new_sheet_title
}
}
})
body = {
'requests': requests
}
response = service.spreadsheets().batchUpdate(
spreadsheetId=spreadsheetId,
body=body).execute()
=IMPORTXML(
"http://shop.marlin.com.ua/products/gidrokostyum-marlin-skiff-20-7-mm";
"(//div[@class='mainTool']//p[1]//span[@class='prices'])[1]"
)
=B1+INT(B2)-INT((TODAY()))
, где В1
- заданное число, В2
- начальная дата.=B1+B2-TODAY()
=8+INT(DATE(2019;1;21))-INT((TODAY()))
, 8
- заданное число, DATE(2019;1;21)
- начальная дата=8+DATE(2019;1;21)-TODAY()
myFunction
на что-то вроде:function recordToMain(){
// Берет диапазон 'Источник!B4:B8' активной Таблицы, т.о. это встроенный скрипт
var data = SpreadsheetApp.getActive().getRange('Источник!B4:B8')
.getValues().map(function(row){return row[0];});
var url = 'https://script.google.com/macros/s/ZZZ/exec';
var options = {
method: 'POST',
headers: {
ContentType: 'application/json'
},
payload: JSON.stringify(data),
muteHttpExceptions: true
};
UrlFetchApp.fetch(url, options);
};
function doPost(e) {
SpreadsheetApp.openById('YYY') // Должна существовать
.getSheetByName('Приемник') // Должен быть лист 'Приемник'
.appendRow([new Date()].concat(JSON.parse(e.postData.contents)));
}
url_master
для первой функции. =IFERROR(IMPORTXML("https://www.youtube.com/watch?v=EJVSx6CUFFc";
"(//*[contains(@class,'like-button-renderer-like-button')])[1]");0)
=IF(
ISNA(IMPORTXML("https://www.youtube.com/watch?v=EJVSx6CUFFc";
"(//*[contains(@class,'like-button-renderer-like-button')])[1]"));
0;
IMPORTXML("https://www.youtube.com/watch?v=EJVSx6CUFFc";
"(//*[contains(@class,'like-button-renderer-like-button')])[1]")
)
> new String('Hello world!') == 'Hello world!'
<· true
> new String('Hello world!') === 'Hello world!'
<· false
/**
* @param {GoogleAppsScript.Spreadsheet.Sheet} sheet Лист Таблицы
* @param {number} column Номер столбца
* @param {number} [startRow] Пропускает количество строк сначала
* @param {number} [numColums] Количество возвращаемых колонок
* @returns {Object[][]} Массив значений
* @see {@link https://toster.ru/q/549725}
*/
var getValuesFromColumn = function(sheet, column, startRow, numColums) {
startRow = startRow || 1;
numColums = numColums || 1;
var lastRow = sheet.getLastRow();
return sheet
.getRange(startRow, column, lastRow - startRow + 1, numColums)
.getValues();
};
var arr = getValuesFromColumn(mainSheet, 3, 3, 2);
from __future__ import print_function
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
from qs import CreateMessage, SendMessage
SCOPES = 'https://www.googleapis.com/auth/gmail.send'
def main():
"""Shows basic usage of the Gmail API.
Lists the user's Gmail labels.
"""
store = file.Storage('token.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('gmail', 'v1', http=creds.authorize(Http()))
message = CreateMessage('xxx@gmail.com',
'yyy@inbox.ru',
'test',
'https://docs.google.com/spreadsheets/d/xxx/edit?usp=sharing')
SendMessage(service, 'me', message=message)
if __name__ == '__main__':
main()
/**
* Get an array of all LinkUrls in the document. The function is
* recursive, and if no element is provided, it will default to
* the active document's Body element.
*
* @param {Element} element The document element to operate on.
* .
* @returns {Array} Array of objects, vis
* {element,
* startOffset,
* endOffsetInclusive,
* url}
*/
function getAllLinks(element) {
var links = [];
element = element || DocumentApp.getActiveDocument().getBody();
if (element.getType() === DocumentApp.ElementType.TEXT) {
var textObj = element.editAsText();
var text = element.getText();
var inUrl = false;
for (var ch=0; ch < text.length; ch++) {
var url = textObj.getLinkUrl(ch);
if (url != null) {
if (!inUrl) {
// We are now!
inUrl = true;
var curUrl = {};
curUrl.element = element;
curUrl.url = String( url ); // grab a copy
curUrl.startOffset = ch;
}
else {
curUrl.endOffsetInclusive = ch;
}
}
else {
if (inUrl) {
// Not any more, we're not.
inUrl = false;
links.push(curUrl); // add to links
curUrl = {};
}
}
}
}
else {
var numChildren = element.getNumChildren();
for (var i=0; i<numChildren; i++) {
links = links.concat(getAllLinks(element.getChild(i)));
}
}
return links;
}