如何在Google表格中返回以逗号分隔的单元格范围字符串? [英] How to return comma-delimited string of range of cells in Google Sheets?

查看:38
本文介绍了如何在Google表格中返回以逗号分隔的单元格范围字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google表格,并编写了一个自定义函数,该函数将一系列单元格作为参数并返回一个字符串,该字符串在单元格的内容中添加了定界逗号.

I am using Google Sheets and writing a custom function that takes in a range of cells as parameter and returns a string that adds a delimiting comma to the contents of the cell.

例如,我们有一个范围 B1:B2 ,其中单元格B1包含"B1_contents" ,单元格B2包含"B2_contents" .该函数应返回"B1_contents,B2_contents" .

For example, we have a range B1:B2 where cell B1 contains "B1_contents" and cell B2 contains "B2_contents". The function should return "B1_contents, B2_contents".

如何使用Google Apps脚本在Google表格中完成此操作?

How can this be done in Google Sheets using Google Apps Script?

推荐答案

您可以尝试以下操作:

function rangeToStringSep(range, sep) {
  return range.toString().split(',').join(sep);
}

使用:

=rangeToStringSep(B1:B3; ", ")

更新

function rangeToStringSep1(range, sep) {
  return range.join(sep);
}

这篇关于如何在Google表格中返回以逗号分隔的单元格范围字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆