兴趣点自动过滤器 [英] POI Auto Filter

查看:37
本文介绍了兴趣点自动过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 Apache POI 在 Excel 2007 文档中预定义自动筛选区域?

How do I use Apache POI to pre-define an auto-filter region in an Excel 2007 document?

一个小的代码示例或链接会很好.

A small code example or link would be nice.

推荐答案

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

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

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

例如,来自下面的表格.

For example, from the sheet below.

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

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

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

这篇关于兴趣点自动过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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