问题描述
我还很新,尝试做与-在不使用添加列的情况下获取所有未隐藏的行.使它通用,以便无论用于隐藏行的字段是什么,我都将仅作用于非隐藏行.我一直在玩isRowHiddenByFilter()和isRowHiddenByUser(),但没有得到它.要获取所有未过滤的行,我是否需要检查isRowHiddenByFilter()和isRowHiddenByUser()均为假?
I'm fairly new, trying to do the same thing as Only get non-filtered values for Google App Script getRange- get all rows that aren't hidden without using an added column. Make it generic so that regardless of what fields were used to hide rows, I'll only be acting on the non-hidden. I've been playing with isRowHiddenByFilter() and isRowHiddenByUser() but not getting it. To get all unfiltered rows, would I need to check that isRowHiddenByFilter() and isRowHiddenByUser() are both false?
似乎上面的代码应该与类似的东西一起工作(不确定如何指定NOT):
It seems like the above should work with something like (not sure how the NOT is specified):
for(var i=0;i<range.length;i++){
if (NOT range.isRowHiddenByFilter){
filter.push(range[i][0])
}}
推荐答案
流:
- 获取所有值并使用 Array.过滤器以过滤出隐藏的行
- Get All values and use Array.filter to filter out hidden rows
Flow:
const getVisibleValues_ = (shtName, rngString, sheet, range) => {
sheet = sheet || SpreadsheetApp.getActive().getSheetByName(shtName);
return (range || sheet
.getRange(rngString))
.getValues()
.filter(
(_, rowIdx) =>
!sheet.isRowHiddenByFilter(rowIdx + 1) &&
!sheet.isRowHiddenByUser(rowIdx + 1)
);
};
const test1 = () => console.info(getVisibleValues_('Sheet1', 'B1:B70'));
这篇关于仅使用isRowHiddenByFilter或isRowHiddenByUser获取Google App脚本getRange的未过滤值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!