在Excel Online中按日期筛选单元格,并包含空白单元格

前端开发 2026-07-12

我想在一列中筛选数据,让结果显示大于今天日期(todaysInt)所表示的数字,其格式为YYYYMMDD。并且希望在同一列的筛选中包含空白单元格。

据我所知,下面的代码之所以不起作用,是因为 "" 不能与数字(todaysInt)一起传入吗?

我查阅了关于citerion1的资料,虽然这是一个深入的主题,但我希望得到关于更直接可行的最佳实践的建议。

table1.getColumnByName("DATASET1").getFilter().applyCustomFilter("<>");

table1
  .getColumnByName("DATASET7")
  .getFilter()
  .applyCustomFilter("", ">=" + todaysInt.toString());

解决方案

你已经相当接近了:

function main(workbook: ExcelScript.Workbook) {
let table1 = workbook.getTable("Table1");
// Clear filter on table table1 column "DATASET1"
table1.getColumnByName("DATASET1").getFilter().clear();
// Clear filter on table table1 column "DATASET7"
table1.getColumnByName("DATASET7").getFilter().clear();
// Apply custom filter on table table1 column "DATASET1"
table1.getColumnByName("DATASET1").getFilter().applyCustomFilter("<>");
// Apply custom filter on table table1 column "DATASET7"
const today = new Date();
const formattedToday = today.toLocaleDateString("en-us");
table1.getColumnByName("DATASET7").getFilter().applyCustomFilter("<>","=" + formattedToday);
}
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章