Apache POI Locking Header Rows

后端 未结 3 1989
無奈伤痛
無奈伤痛 2021-01-31 13:26

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

3条回答
  •  一向
    一向 (楼主)
    2021-01-31 13:52

    To do this, you can create a freeze pane as follows:

    workbook.getSheetAt(workbook.getActiveSheetIndex()).createFreezePane(0, 1);
    

    This will freeze the first row in place. There's another method with more options, so check out the API.

    The only thing to note would be if you're using XSSF workbooks - there is a mention of a bugfix in version 3.8-beta3 that fixed the behavior of freeze panes using XSSF spreadsheets:

    50884 - XSSF and HSSF freeze panes now behave the same(poi-developers)

    I don't know the details of this, but it would be worth investigating if you're in that boat.

提交回复
热议问题