יצירת תפריט אישי:
//Creates a custom menu
function CreateMyMenu(){
const myUi=SpreadsheetApp.getUi();
myUi.createMenu('דואלים')
.addItem('קפוץ לדף הפתיחה Goto Home', 'gotoHome')
.addItem('כיוון דף RTL-LTR', 'RTLsheet')
.addToUi();
} //of misCreateMenu()
שתי האפשרויות בתפריט:
קפיצה ללוח בקשה:
function gotoHome(){
const allSheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
if (allSheets.length>0){
allSheets[0].getRange('A1').activate();
} else {
Logger.log("Error from gotoHome():Spreadsheet contains no sheets.");
}
}//of gotoHome()
החלפת כיוון הגליון:
function RTLsheet() {
var curDir=CUR_SS.getActiveSheet().isRightToLeft();
CUR_SS.getActiveSheet().setRightToLeft(!curDir);
}//of RTLsheet()
עכשיו להוסיף בראש את הוספת התפריט בעת פתיחת הקובץ:
function onOpen() {
CreateMyMenu();
gotoHome();
}//of onOpen()
תאריך נוכחי בפורמט ישראלי (dd/mm/yyyy):
function currentDate() {
var now = new Date();
var timeZone = 'Asia/Jerusalem';
var format = "dd/MM/yyyy";
return Utilities.formatDate(now, timeZone, format);
} //of currentDate()