function importDataFromAnotherSheet() {
var sourceSheet = SpreadsheetApp.openById("1uM5srecV1-bQ_RGIFhH_-W6uA68UjJwg5RT1TdyABls");
var sourceRange = sourceSheet.getSheetByName("Лист1").getDataRange();
var sourceValues = sourceRange.getValues();
var destinationSheet = SpreadsheetApp.getActiveSpreadsheet();
var destinationRange = destinationSheet.getSheetByName("Лист2").getRange();
if (sourceValues.length <= destinationRange.getNumRows() && sourceValues[0].length <= destinationRange.getNumColumns()) {
destinationRange.setValues(sourceValues);
Logger.log("Данные успешно импортированы.");
} else {
Logger.log("Целевая область недостаточно большая для копирования всех данных.");
}
}
myForm.addEventListener("submit", async (event) => {
event.preventDefault();
try {
const form = new FormData(myForm);
const response = await fetch("form-send.php", {
method: "POST",
body: form
});
if (!response.ok) {
throw new Error("Network response was not ok.");
}
modal.classList.add('open');
await new Promise(resolve => setTimeout(resolve, 2000));
modal.classList.remove('open');
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
});
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuSheet = ss.getSheetByName("Menu");
var partSheet = ss.getSheetByName("Parts");
var partCell = menuSheet.getRange('A1');
var partLastRow = partSheet.getLastRow();
var partRange = partSheet.getRange('A1:A' + partLastRow);
var partRule = SpreadsheetApp.newDataValidation().requireValueInRange(partRange).build();
partCell.setDataValidation(partRule);
}
function selectList(){
var sheetName = SpreadsheetApp.getActive().getRange("A1").getValue();
var sheet = SpreadsheetApp.getActive().getSheetByName(sheetName)
sheet.activate()
}