将电子表格字符串拆分为数组值 [英] Splitting spreadsheet strings into array values

查看:50
本文介绍了将电子表格字符串拆分为数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将一个单元格中的值拆分为单独的数组值.我正在从电子表格中获取电子邮件列表,并且需要使用 addCommenters()方法.

I need to split a value from a cell into separate array values. I am taking a list of emails from my spreadsheet and need to use the addCommenters() method.

电子表格单元格值: email1@email.com,email2@email.com,email3@email.com ...等等.

Spreadsheets cell value: email1@email.com, email2@email.com, email3@email.com ... etc.

我需要正确地拆分," ,以将数组传递到 addCommenters()中.

I need to split around the ", " properly to pass the array into addCommenters().

执行此操作的编程方式是什么?

What is the programmatic way to do this?

推荐答案

如果获取该单元格的值(使用.getValue())

If you get the value of that cell (using .getValue())

var emails = sheet.getRange(range_here).getValue()

,然后应用 split()方法

var commentersArray = emails.split(",")

您将拥有一个数组,可以将其传递给.addCommenters()方法.

you will have an array you can pass to the .addCommenters() method.

file.addCommenters(commentersArray);

这篇关于将电子表格字符串拆分为数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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