在Google Apps Script中返回“范围”而不是实际字符串
Returning 'Range' instead of actual string in Google Apps Script
我使用以下函数在Google表格中返回串联字符串。在这种情况下,B4等于"心脏病学",B1等于"82-01"。
预期结果是dimension2=~cardiology;ga:eventCategory=~MS82-01
。
但是,我得到了这个结果,dimension2=~Range;ga:eventCategory=~MSRange
.
为什么函数返回"范围"而不是实际字符串?
function highLevelData() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); // get the spreadsheet object
SpreadsheetApp.setActiveSheet(spreadsheet.getSheets()[1]); // set the first sheet as active
var sheet = spreadsheet.getActiveSheet(); // get the active sheet
var reportConfig = spreadsheet.getSheets()[0]; // set report configuration sheet
var targetSpecialty = sheet.getRange("B4"); // get target specialty
var specialtyDimension = "dimension2=~"; // set the sytanx string for the specialty dimension
var targetCase = sheet.getRange("B1"); // get case
var eventCategoryDimension = ";ga:eventCategory=~MS"; // set the syntax string for the event category dimension
var filterOutput = specialtyDimension + targetSpecialty + eventCategoryDimension + targetCase; // concatenate full filter string
var filterCell = reportConfig.getRange("B11"); // set the filter cell
filterCell.setValue(filterOutput); // output filter string to filter cell
}
"getRange()" 函数返回一个 Range 对象,该对象表示工作表中的单元格。
若要获取单元格的内容,请在 Range 对象上调用".getValue()"。
var targetSpecialty = sheet.getRange("B4").getValue();
请参阅:https://developers.google.com/apps-script/reference/spreadsheet/range
相关文章:
- 需要创建一个函数,将我自己创建的范围对象转换为字符串
- 使用jquery感知文本字符串中的时间范围
- 识别和替换 html 字符串中的格式化日期范围
- 如何将当前时间与使用 Javascript 格式化为字符串的时间范围进行比较
- 使用字符串作为函数调用范围
- 如何删除字符串中的索引位置范围
- AJAX 将范围字符串替换为外部日期字符串
- 如何检测字符串中的特定范围是否在换行符中
- 检查字符串是否以范围内的数字开头
- 将字符串差异计算为范围
- 使用 HTML 中的字符串访问范围键
- 在Google Apps Script中返回“范围”而不是实际字符串
- JQuery表分拣机没有'不能使用日期范围字符串
- Moment JS或ISO字符串的日期范围库
- 如何在js中验证字符串只包含来自多个unicode范围的字符
- 在表单选择的日期范围字符串中查找当前日期
- 隔离范围'='传递字符串而不是对象
- 如何在jquery中从字符串中获取范围
- Angular:在控制器中渲染包含范围变量的外部化字符串
- Handsontable:从坐标中获取字符串范围