/* eslint-disable require-jsdoc */
/* eslint-disable no-undef */
function doAction() {
var result = readBaseData('22-05-2019');
// If found data for this date...
if (result != null) {
var doc = createNewDoc(' iskovoe ' + result[0][0]);
fillTemplate(doc, result);
}
}
// inDoc - its a empty template, inData - data for filling template
function fillTemplate(inDoc, inData) {
// Getting count of files in folder
var NUM = DocsList.getFolderById(
'1a3uCa9wRyOzio-C7FVacOykuLoxCqTs3'
).getFiles().length;
// Replace masks (Don't work [NUM] or $NUM or something else)
inDoc.replaceText(
'x',
'https://docs.google.com/spreadsheets/d//edit#gid=0...'
);
inDoc.replaceText(
'x',
'https://docs.google.com/spreadsheets/d//edit#gid=0...'
);
inDoc.replaceText(
'x',
'https://docs.google.com/spreadsheets/d//edit#gid=0...'
);
inDoc.replaceText(
'x',
'https://docs.google.com/spreadsheets/d//edit#gid=0...'
);
// get first table in document
var table = curDoc.getTables()[0];
for (i = 0; i < inData.length; i++) {
var row = table.appendTableRow();
row.appendTableCell(inData[i][1]);
row.appendTableCell(inData[i][2]);
}
curDoc.saveAndClose();
}
function createNewDoc() {
// Making copy of blank file
var blankDoc = DocsList.getFileById(
'19vYiThaKdgQ6eeiRg5nPewzP_Eab7nkLUwyt49jCC1Q'
).makeCopy(iskovoe);
blankDoc.addToFolder(
DocsList.getFolderById('1a3uCa9wRyOzio-C7FVacOykuLoxCqTs3')
);
// return working doc and table base
return (curDoc = DocumentApp.openById(blankDoc.getId()));
}
// get range and sort only for day from parameter
function readBaseData(inDate) {
var ssDoc = SpreadsheetApp.openById(
'1ZCNO6Iae2RwDdKAlQX6TF5mpp4xHHB4v1mXK233uJls'
).getActiveSheet();
// get filled range
var data = ssDoc.getDataRange().getValues();
// create new array with data to inDate,
// for start from 1 because first row is text column headers
var filteredData = new Array([]);
for (i = 1; i < data.length; i++) {
data[i][0] = convertDate(data[i][0]);
if (data[i][0] == inDate && data[i][3] == 1) {
filteredData[i - 1] = data[i];
}
}
return filteredData;
}
C2:F18
верно=ARRAYFORMULA(SUMIF(IF(COLUMN(C1:F1);ROW(A2:A18));ROW(A2:A18);C2:F18))
MMULT
.=MMULT(C2:F18;TRANSPOSE(ARRAYFORMULA(COLUMN(C1:F1)^0)))
D3:U
верно=ARRAYFORMULA(IF(ROW(D3:D11);MMULT(N(D3:U);TRANSPOSE(N(MOD(COLUMN(D3:U);3)={1;0})));))
/**
* Returns a consecutive array of the counts of sequences.
*
* @param {Sheet3!B1:B34} reference A range.
* @returns The counts of sequences.
* @customfunction
*/
function COUNT_CONSECUTIVE( reference ){
try{
return reference.reduce(function(p, v, i, arr){
if(i === 0 || arr[i][0] !== arr[i - 1][0])
p.push([v[0], 1]);
else
p[p.length-1][1]++;
return p;
}, []);
} catch(err){
return err.message
}
}
A2:A10
верно, что все группы без номеров с их количествами можно получить как=COUNT_CONSECUTIVE(A2:A10)
'cat'
верно=QUERY(COUNT_CONSECUTIVE(A2:A9),"select max(Col2) where Col1='cat' label max(Col2)''")
=ARRAYFORMULA(QUERY({A2:A10,VLOOKUP(ROW(A2:A10),IF(IF(A2:A10<>A1:A9,ROW(A2:A10),0)>0,{ROW(A2:A10),IF(A2:A10<>A1:A9,ROW(A2:A10),0)},),2),IF(IF(A2:A10<>A1:A9,ROW(A2:A10),0)=0, COUNTIFS(ROW(A2:A10),">=" & VLOOKUP(ROW(A2:A10),IF(IF(A2:A10<>A1:A9,ROW(A2:A10),0)>0,{ROW(A2:A10),IF(A2:A10<>A1:A9,ROW(A2:A10),0)},),2),ROW(A2:A10),"<="&ROW(A2:A10)),1)},"select Col1,max(Col3) group by Col2,Col1 label max(Col3)''"))
A2:A10
верно, что все группы без номеров с их количествами можно получить как'cat'
верно=ARRAYFORMULA(QUERY(QUERY({A2:A10,VLOOKUP(ROW(A2:A10),IF(IF(A2:A10<>A1:A9,ROW(A2:A10),0)>0,{ROW(A2:A10),IF(A2:A10<>A1:A9,ROW(A2:A10),0)},),2),IF(IF(A2:A10<>A1:A9,ROW(A2:A10),0)=0, COUNTIFS(ROW(A2:A10),">=" & VLOOKUP(ROW(A2:A10),IF(IF(A2:A10<>A1:A9,ROW(A2:A10),0)>0,{ROW(A2:A10),IF(A2:A10<>A1:A9,ROW(A2:A10),0)},),2),ROW(A2:A10),"<="&ROW(A2:A10)),1)},"select Col1,max(Col3) group by Col2,Col1 label max(Col3)''"),"select max(Col2) where Col1='cat' group by Col1 label max(Col2)''"))
'cat'
справедливо также=ARRAYFORMULA(MAX(FREQUENCY(ROW(A2:A10),ROW(A2:A10)*(A2:A10<>"cat")))-1)
=ARRAYFORMULA(VLOOKUP(B10:B13;E2:F6;2;1))
https://drive.google.com/drive/search?q=type:document%20%D0%B4%D0%BB%D1%8F
embedded=true
<iframe src="https://docs.google.com/viewerng/viewer?url=https://cit.tsn.47edu.ru/doc/Programma_provedenia_regionalnykh_UTS_24_11_2018.docx&embedded=true">
</iframe>
<iframe src="https://view.officeapps.live.com/op/embed.aspx?src=https://cit.tsn.47edu.ru/doc/Programma_provedenia_regionalnykh_UTS_24_11_2018.docx">
</iframe>
IMPORTRANGE
.IMPORTRANGE
и отфильтровать их уже на стороне приемника.var files = DriveApp.searchFiles('mimeType="application/vnd.google-apps.spreadsheet"');
DriveUser
. Это объект системы, поэтому вам необходимо воспользоваться одним из его методов, для получения информации. Например,...
file.getOwner().getEmail()
...
getTime
.function isDate(value){
return value && value.getTime;
}
function isDate(date){
return date instanceof Date && !isNaN(date.valueOf());
}
var birthday1 = ss1.getRange("D8").getValue();
var birthday = isDate(birthday1) ?
Utilities.formatDate(birthday1, "GMT+3", "dd-MM-yyyy") :
undefined;