var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// Получить активную ячейку
var range = sheet.getActiveCell();
// Получить A1-адрес этой ячейки
var a1Address = range.getA1Notation();
// Вывести A1-адрес в лог
Logger.log('A1 address of the active cell is: ' + a1Address);
function myFunction() {
var dateArray = [ 'Thu Jan 11 2024 10:00:00 GMT+0200 (Eastern European Standard Time)' ,
'Fri Jan 12 2024 10:00:00 GMT+0200 (Eastern European Standard Time)',
'Sat Jan 13 2024 10:00:00 GMT+0200 (Eastern European Standard Time)'];
var myUnixTime = Date.parse('2023-01-01 00:00:00'); // my date
dateArray.map(item => {
var unixTime = Date.parse(item); //
console.log(unixTime);
var diff = unixTime - myUnixTime;
console.log(diff); // difference in milliseconds
});
}
var doc = DocumentApp.openById('fileId'); // open google docs
var body = doc.getBody();
body.replaceText('{pid}', '1234567'); // replace placeholders
body.replaceText('{forename}', 'John');
body.replaceText('{surname}', 'Smith');
doc.saveAndClose();
function CopySheet() {
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName("Список");
var ranges = sheet.getDataRange();
var lastRow = ranges.getLastRow();
var names = sheet.getRange(`A1:A${lastRow}`).getDisplayValues(); // get new sheet names array
names = names.filter(name => (name.length > 0)); // delete empty values
// need check by doubles
var sheetSample = ss.getSheetByName('Пример');
names.forEach(name => { // create new sheets
var sheetTemp = sheetSample.copyTo(ss);
sheetTemp.setName(name);
});
Browser.msgBox('Info', 'Completed! Create: ' + names.length + ' sheets', Browser.Buttons.OK);
};