Use sheet.setAutoFilter(CellRangeAddress.valueOf("B1:H1"));
We have to specify only the header cells of the tabular data. Here in my example header starts from cell B1 and ends at cell H1.
Excel will automatically find the data below it and show it in the filter options.