function test_f(){
let s;
s = "123 check";
console.log(`${s} --> ${f(s," ")}`)
s = "ok check";
console.log(`${s} --> ${f(s)}`)
s = "россия, москва";
console.log(`${s} --> ${f(s)}`)
s = "россия москва";
console.log(`${s} --> ${f(s)}`)
s = "привет хабр, вопрос";
console.log(`${s} --> ${f(s)}`)
s = "привет хабр";
};
f = function(s, delimiter){
delimiter = delimiter || ",";
let a = (s+"").split(delimiter).map(x=>x.trim());
return (a.length<=1)?null:a;
};
function getRoyalToysAll(url) {
let xml = UrlFetchApp.fetch(url).getContentText();
let document = XmlService.parse(xml);
let root = document.getRootElement();
let entries = root.getChildren('shop');
let long = entries[0];
let offers = long.getChild('offers').getChildren('offer');
let outData = [];
for (offer of offers) {
let id = offer.getAttribute('id').getValue();
let available = offer.getAttribute('available').getValue();
let price = offer.getChild('price').getValue();
//let stock_quantity = offer.getChild('stock_quantity').getValue();
let description = offer.getChild('description').getValue();
let brend = offer.getChild('brend').getValue();
let currencyId = offer.getChild('currencyId').getValue();
let categoryId = offer.getChild('categoryId').getValue();
let name = offer.getChild('name').getValue();
let vendorCode = offer.getChild('vendorCode').getValue();
let pictures = offer.getChildren('picture').map(el=>el.getValue());
pictures.length=6;
let params = [];
for (let pi=1; pi<=20; pi++){
let param = offer.getChild('param'+pi);
let data = param?[param.getAttribute('name').getValue(),'',param.getValue()]:['','',''];
params.push(...data);
};
let row = [id, available, price, description, brend, currencyId, categoryId, ...pictures, name, vendorCode, ...params];
outData.push(row);
}
return outData;
};
function test_getRoyalToysAll(){
const url = "https://royaltoys.com.ua/my/export/82f668de-8f05-478e-86f3-34224286999c.xml";
const sheetName = "Лист1";
let outData = getRoyalToysAll(url);
const outRange = SpreadsheetApp
.getActiveSpreadsheet()
.getSheetByName(sheetName)
.getRange(1,1,outData.length, outData[0].length);
outRange.setValues(outData);
};
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/"; "Показатель!C2:C")
const formulaTemplate = '=IMPORTRANGE("https://docs.google.com/spreadsheets/d/"; "Показатель!C2")';
let range = spreadsheet.getRange('C2:C1240');
let formulas = range.getFormulas();
formulas = formulas.map((row,ri)=>row.map(f=>formulaTemplate.replace('!C2', '!C'+(ri+2))));
range.setFormulas(formulas);
/**
* Считает средний процент каждого игрока за месяц
* Telegram - @ProgrammerForever
*
* @param {range} data Исходные данные
* @return Средний процент каждого игрока за месяц
*/
function calc(data){
let sums = data[0]
.map((_, col) => data.map(row => row[col]))
.map(c=>c.reduce((a,v)=>a+=v,0));
let fractions = data.map((row,r)=>row.map((v,c)=>v/sums[c]));
return fractions.map(row=>row.reduce((a,v)=>a+=v,0));
};
const targetEmail = ``; // email для отправки
function f(){
let ss = SpreadsheetApp.getActiveSpreadsheet();
let blob = ss.getAs(`application/pdf`);
try{
GmailApp.sendEmail(targetEmail, 'backup', 'pdf файл во вложении', {
attachments: [blob],
});
Logger.log(`Письмо отправлено`);
}catch(e){
Logger.log(e);
}
};
x = x0 + R*cos(phi)
y = y0 + R*cos(pi/2 - phi) = y0 + R*sin(phi)
/**
* Возвращает примечание к ячейке
* Telegram - @ProgrammerForever
*
* @param {string} sheetName Имя листа
* @param {string} rangeName Адрес ячейки в текстовом виде
* @return Возвращает примечание к ячейке
* @customfunction
*/
function getNotes(sheetName, rangeName){
return SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName).getRange(rangeName).getNotes()
}
=getNotes("Лист1";"A10")
=getNotes("Лист1";"A10:B15")
Public Function getShortName(strText As Variant) As String
Dim myRegExp As New RegExp
Dim matches As MatchCollection
myRegExp.Global = True
myRegExp.IgnoreCase = True
myRegExp.Pattern = "(\S+)\s+(\S)\S*\s+(\S)\S*"
Set matches = myRegExp.Execute(strText)
getShortName = matches(0).SubMatches(0) & " " & matches(0).SubMatches(1) & "." & matches(0).SubMatches(2) & "."
End Function
Function getShortName(strText As String) As String
Dim a
a = Split(strText, " ")
getShortName = a(0) & " " & Left(a(1), 1) & "." & Left(a(2), 1) & "."
End Function
sin(x) = x - x³/(3!) + x⁵/(5!) - x⁷/(7!) + x⁹/(9!) - ...
3й - 10000*0,9 =9000 (разряд 3го)
2й - 10000*0,9*0,9*0,9 = 7290 (разряд 2го, заряд 3го, разряд 3го)
1й - 10000*0,9*0,9*0,9*0,9*0,9 = 5904,9 (разряд 1го, заряд 2го, разряд 2го, заряд 3го, разряд 3го)