How to hide the summary rows and columns using XlsIO?

3 Nov 20252 minutes to read

You can hide the summary rows and columns by using the IsSummaryRowBelow and IsSummaryColumnRight properties. The following code snippet illustrates this.

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

  //Hide the summary rows at the bottom
  worksheet.PageSetup.IsSummaryRowBelow = false;

  //Hide the summary columns to the right
  worksheet.PageSetup.IsSummaryColumnRight = false;

  workbook.SaveAs("SuppressRowsColumns.xlsx");
  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];

  //Hide the summary rows at the bottom.
  worksheet.PageSetup.IsSummaryRowBelow = false;

  //Hide the summary columns to the right.
  worksheet.PageSetup.IsSummaryColumnRight = false;

  workbook.SaveAs("SuppressRowsColumns.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)

  'Hide the summary rows at the bottom.
  worksheet.PageSetup.IsSummaryRowBelow = False

  'Suppress the summary columns to the right.
  worksheet.PageSetup.IsSummaryColumnRight = False

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

See Also