我正在使用Google脚本从表格中提取Google表单数据以在Google日历中进行活动。该表格填充两列数据(时间戳和数字)。我使用C列中的公式从B列中的数据生成标题。无论我做什么,我都只能将B列中的数据显示在日历中。
// function to retrieve data from Sheet and add to Calendar
function simpleSheetsToCalendar() {
// get spreadsheet
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Sheet1');
// get the data from Google Sheet
var data = sheet.getRange(sheet.getLastRow(),1,1,3).getValues();
// create variables
var date = data[0][0];
var title = data[0][3];
// get calendar
var masterCal = CalendarApp.getCalendarById('[email protected]');
// add to calendar
masterCal.createAllDayEvent(title,date);
}
您需要将此改变var title = data[0][3];
这一var title = data[0][2];
列从1开始。数组索引从零开始。因此data [0] [2]实际上是第3列数据。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句