How to unfreeze the rows and columns in XlsIO?

8 Dec 20232 minutes to read

You can unfreeze rows and columns in XlsIO by using the RemovePanes method. The following code snippet illustrates this.

using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
  IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
  IWorksheet worksheet = workbook.Worksheets[0];

  //Freeze the panes
  worksheet.Range[8, 1].FreezePanes();

  //Unfreeze the panes
  worksheet.RemovePanes();

  FileStream stream = new FileStream("Unfreeze.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
  workbook.SaveAs(stream);
  workbook.Close();
  excelEngine.Dispose();
}
using (ExcelEngine excelEngine = new ExcelEngine())
{
  IApplication application = excelEngine.Excel;
  application.DefaultVersion = ExcelVersion.Excel2013;
  IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
  IWorksheet worksheet = workbook.Worksheets[0];

  //Freeze the panes
  worksheet.Range[8, 1].FreezePanes();

  //Unfreeze the panes
  worksheet.RemovePanes();

  workbook.SaveAs("Unfreeze.xlsx");
}
Using excelEngine As ExcelEngine = New ExcelEngine()
  Dim application As IApplication = excelEngine.Excel
  application.DefaultVersion = ExcelVersion.Excel2013
  Dim workbook As IWorkbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic)
  Dim worksheet As IWorksheet = workbook.Worksheets(0)

  'Freeze the panes
  worksheet.Range(8, 1).FreezePanes()

  'Unfreeze the panes
  worksheet.RemovePanes()

  workbook.SaveAs("Unfreeze.xlsx")
End Using

See Also