数据:
第1行 - 有一些公式和格式
第2行 - 列名称为
该装置将根据当天的增加或减少,例如,一天许多将有20和其他3。
所有活动都将创建&从电子表格更新,因为我们为它创建了一个独家日历。
我们每天都有很多电话,而且非常考虑使用日历创建活动。 这就是为什么我们有一个电子表格,当我们修改B列时,所有信息都会自动更新。
重要提示:我们更新了开始和放大每15或30分钟结束一次,因为我们管理重大事件。
未检查列H
/**
* Adds a custom menu to the active spreadsheet, containing a single menu item
* for invoking the exportEvents() function.
* The onOpen() function, when defined, is automatically invoked whenever the
* spreadsheet is opened.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Export Events",
functionName : "exportEvents"
}];
sheet.addMenu("Calendar Actions", entries);
};
/**
* Export events from spreadsheet to calendar
*/
function exportEvents() {
var sheet = SpreadsheetApp.getActiveSheet();
if (sheet.getName() == "Sheet1"){
var activeCell = sheet.getActiveCell(); //Detec the ActiveCell
var row = activeCell.getRow(); //Detect the ActiveRow
var headerRows = 2; // Number of rows of header info (to skip)
var range = sheet.getDataRange();
var data = range.getValues();
var calId = "8au195cppi3smt6m138cgjpr3o@group.calendar.google.com";
var cal = CalendarApp.getCalendarById(calId);
for (i in data) {
if (i < headerRows) continue; // Skip header row(s)
var row = data[i];
var title = row[0]; // [0] First column// [1] Second column
var tstart = row [5];
var tstop = row [8];
var desc = row[1];
var id = row[9]; // Nine column == eventId
// Check if event already exists, delete it if it does
try {
var event = cal.getEventSeriesById(id);
event.deleteEventSeries();
row[9] = ''; // Remove event ID
}
catch (e) {
// do nothing - we just want to avoid the exception when event doesn't exist
}
//cal.createEvent(title, new Date("March 3, 2010 08:00:00"), new Date("March 3, 2010 09:00:00"), {description:desc,location:loc});
var newEvent = cal.createEvent(title, tstart, tstop, {description:desc}).getId();
row[9] = newEvent; // Update the data array with event ID
debugger; }
// Record all event IDs to spreadsheet
range.setValues(data);
}
}
答案 0 :(得分:0)
尝试改变
data = range.getValues();
到
data = range.getDisplayValues();
据我所知,getDisplayValues 将检索单元格的字符串值