简体   繁体   English

如何使用java apache poi从Excel工作表中的仅少数列中删除过滤器,而不是所有列中删除过滤器

[英]how to delete filters from only few columns in the excel sheet not all of the columns using java apache poi

I have applied filters to the excel sheet columns A7 to M7 using the method sheet.setAutoFilter(CellRangeAddress.valueOf("A7:M7")); 我已使用sheet.setAutoFilter(CellRangeAddress.valueOf("A7:M7"));方法将过滤器应用于excel表格A7至M7列sheet.setAutoFilter(CellRangeAddress.valueOf("A7:M7")); but now I want to remove filters from the column J7,K7 and L7 but couldn't find any method in apache poi 3.17 但是现在我想从列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));                                                               
    }

No, there is not a method present which excludes some of the columns from a range. 不,没有一种方法可以从范围中排除某些列。 But you can try by splitting the range based on the exclude columns. 但是您可以尝试根据排除列拆分范围。 The MsExcel supports ranges with commas which will work here. MsExcel支持带逗号的范围,在这里可以使用。

sheet.setAutoFilter(CellRangeAddress.valueOf("A7:M7")); 

The range can be changed to (if J7,K7 and L7 are excluded), 范围可以更改为(如果排除了J7,K7和L7),

sheet.setAutoFilter(CellRangeAddress.valueOf("A7:I7, M7:M7"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM