freezePanes method

void freezePanes()

Creates freeze panes that keep the selected rows and columns visible in the range while scrolling the worksheet.

final Workbook workbook = Workbook();
final Worksheet worksheet = workbook.worksheets[0];
worksheet.getRangeByName('A1:H10').text = "Freeze panes";
worksheet.getRangeByName('B2').freezePanes();
final List<int> bytes = workbook.saveAsStream();
saveAsExcel(bytes, 'FreezePanes.xlsx');
workbook.dispose();

Implementation

void freezePanes() {
  worksheet.isfreezePane = true;
  worksheet.horizontalSplit = row - 1;
  worksheet.verticalSplit = column - 1;
  worksheet.topLeftCell = worksheet.getRangeByIndex(row, column).addressLocal;
  if (row > 1 && column > 1) {
    worksheet.activePane = ActivePane.bottomRight;
  } else if (row > 1 && column <= 1) {
    worksheet.activePane = ActivePane.bottomLeft;
  } else if (row <= 1 && column > 1) {
    worksheet.activePane = ActivePane.topRight;
  } else {
    worksheet.activePane = ActivePane.topLeft;
  }
}