【发布时间】:2022-10-17 06:49:53
【问题描述】:
这是我现在拥有的代码,我想做的也是从 C 中引入所有数据,其中文本不包括 col A 中的“250p”。
const sS = SpreadsheetApp.getActiveSpreadsheet()
function grabData() {
const sheetIn = sS.getSheetByName('data')
const sheetOut = sS.getSheetByName('Desired Outcome')
const range = 'A2:B'
/* Grab all the data from columns A and B and filter it */
const values = sheetIn.getRange(range).getValues().filter(n => n[0])
/* Retrieve only the names if it containes 250p */
/* In format [[a], [b], ...] */
const parsedValues = values.map((arr) => {
const [type, name] = arr
if (type.toLowerCase().includes('250p')) {
return name.split('\n')
}
})
.filter(n => n)
.flat()
.map(n => [n])
/* Add the values to the Desired Outcome Sheet */
sheetOut
.getRange(sheetOut.getLastRow() + 1, 1, parsedValues.length)
.setValues(parsedValues)
}
我试着做:
if (!type.toLowerCase().includes('250p')) {
if (type.whenTextDoesNotContain('250p')) {
但在这两种情况下,我都明白,这不是一个功能。
【问题讨论】:
标签: if-statement google-apps-script google-sheets data-extraction