参数(字符串,数字)与getRange()的方法签名不匹配

编程入门 行业动态 更新时间:2024-10-12 05:50:58
本文介绍了参数(字符串,数字)与getRange()的方法签名不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试编写一个脚本来从Google Analytics(分析)中获取数据.我在许多网站和youtube视频的帮助下编写了此文件,但无法解决我的代码中的1个问题.

I am trying to write a script to fetch data from Google Analytics. I wrote this using help from lots of sites and youtube videos but unable to fix 1 issue in my code.

function myFunction() { var app = SpreadsheetApp var doc = app.getActiveSpreadsheet().getActiveSheet(); for(var i=0;i<107;i++){ var viewId = doc.getRange(i+2,1).getValue(); // Your Google Analytics view ID var startDate = Utilities.formatDate(doc.getRange("K1").getValue(), "GMT+2", "yyyy-MM-dd"); var endDate = Utilities.formatDate(doc.getRange("K2").getValue(), "GMT+2", "yyyy-MM-dd");; var metric = 'ga:sessions, ga:newUsers, ga:bounceRate'; var option = {'segment': 'gaid::reM9CWAgR0ys4_Ng4N_aVw'}; var result = Analytics.Data.Ga.get(viewId, startDate, endDate, metric, option); // Make the request var sessions = result.totalsForAllResults['ga:sessions']; var newusers = result.totalsForAllResults['ga:newUsers']; var bouncerate = result.totalsForAllResults['ga:bounceRate']; var doc = app.getActiveSpreadsheet(); // Current document var sheet = doc.getActiveSheet(); // Current sheet sheet.getRange(i+2,2,1,1).setValue(sessions); // Write total sessions sheet.getRange(i+2,3,1,1).setValue(newusers); // Write toal newusers sheet.getRange(i+2,4,1,1).setValue(bouncerate); // Write total bouncerate } }

推荐答案

一旦我更改了工作表中的视图ID,此问题就会自动解决.我想问题出在视图ID

This Got auto resolved once I changed the View ID in my sheet. I guess the problem was with view ID

更多推荐

参数(字符串,数字)与getRange()的方法签名不匹配

本文发布于:2023-11-15 14:19:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1595192.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   不匹配   参数   数字   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!