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.
Can I so this using POI?
Setting filter on headers of an Excel sheet via POI
Re: Setting filter on headers of an Excel sheet via POI
Save the first and last cell from filter area, and execute:
```
sheet.setAutoFilter(new CellRangeAddress(firstCell.getRow(), lastCell.getRow(), firstCell.getCol(), lastCell.getCol()));
```
For example, from the below sheet.
```
>x (x, y)
0123456
0|--hhh--| h = header
1|--+++--| + = values
2|--+++--| - = empty fields
3|--+++--|
4|
```
sheet.setAutoFilter(new CellRangeAddress(firstCell.getRow(), lastCell.getRow(), firstCell.getCol(), lastCell.getCol()));
```
For example, from the below sheet.
```
>x (x, y)
0123456
0|--hhh--| h = header
1|--+++--| + = values
2|--+++--| - = empty fields
3|--+++--|
4|