我已使用以下方法将过滤器应用于 Excel 工作表 A7 至 M7 列
sheet.setAutoFilter(CellRangeAddress.valueOf("A7:M7"));
但现在我想从 J7、K7 和 L7 列中删除过滤器,但在 apache poi 3.17 中找不到任何方法
for(int j=0;j<=12;j++)
{
if(j==9||j==10||j==11)
{
continue;
}
sheet.setAutoFilter(new CellRangeAddress(6,6, j, j));
}
最佳答案
不,不存在从范围中排除某些列的方法。但您可以尝试根据排除列分割范围。 MsExcel 支持带逗号的范围,这将在此处起作用。
sheet.setAutoFilter(CellRangeAddress.valueOf("A7:M7"));
范围可以更改为(如果排除 J7、K7 和 L7),
sheet.setAutoFilter(CellRangeAddress.valueOf("A7:I7, M7:M7"));
关于java - 如何使用java apache poi仅从Excel工作表中的几列而不是所有列中删除过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55570423/