通过POI在Excel工作表的标题上设置过滤器 [英] Setting filter on headers of an Excel sheet via POI

查看:140
本文介绍了通过POI在Excel工作表的标题上设置过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我生成了一个表格,非常漂亮的标准标题和数据列.

I generate a sheet, pretty bog standard headers and columns of data.

我想打开工作表的过滤器"功能,以便用户可以轻松地对数据进行排序和过滤.

I want to turn on the "Filter" function for the sheet, so the user can easily sort and filter the data.

我可以使用POI这么做吗?

Can I so this using POI?

推荐答案

保存过滤器区域中的第一个和最后一个单元格,然后执行:

Save the first and last cell from filter area, and execute:

sheet.setAutoFilter(new CellRangeAddress(firstCell.getRow(), lastCell.getRow(), firstCell.getCol(), lastCell.getCol()));

例如,从下面的页面.

>x         (x, y)
  0123456  
0|--hhh--|   h = header
1|--+++--|   + = values
2|--+++--|   - = empty fields
3|--+++--|
4|-------|

第一个单元格将是第一个+(2,1)单元格上方的标头.最后一个将是最后一个+单元格(5,3)

first cell will be the header above the first + (2,1) cell. The last will be the last + cell (5,3)

这篇关于通过POI在Excel工作表的标题上设置过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆