Java – Apache POI Locking Header Rows

apache-poijava

Is anyone out there familiar with a way to lock a row in a spreadsheet created with Apache POI 3.7? By locking I mean that I want the title row for the columns to remain visible when the user is scrolling through the rows. My created spreadsheet will have 500 rows and it would be beneficial if the column’s names were always visible.

Best Answer

In case you need to Freeze any particular row anywhere in the sheet you can use (Within org.apache.poi.ss.usermodel.Sheet) (Available in POI 3.7 as well)

Sheet.createFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow)

In your case if you want to freeze just your first x rows then the int leftmostColumn, int topRow section will get removed and you can use just

Sheet.createFreezePane(int colSplit, int rowSplit)

for example

sheet1.createFreezePane(0, 5); // this will freeze first five rows
Related Topic