From d2f98a94973a5b39a6b154c4f11b3aa9e5bdef25 Mon Sep 17 00:00:00 2001 From: KarthikaSF4773 Date: Mon, 3 Nov 2025 12:09:29 +0530 Subject: [PATCH] 990137-SlicerUG --- .../Excel/Excel-Library/NET/Slicer.md | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Document-Processing/Excel/Excel-Library/NET/Slicer.md b/Document-Processing/Excel/Excel-Library/NET/Slicer.md index fdc0a219c..9b76a0334 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Slicer.md +++ b/Document-Processing/Excel/Excel-Library/NET/Slicer.md @@ -25,8 +25,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Access the table. @@ -35,9 +34,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Add slicer for the table. sheet.Slicers.Add(table, 3, 11, 2); - FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(stream); - stream.Dispose(); + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} @@ -266,8 +263,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Access the table @@ -306,9 +302,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Slicer style slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2; - FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(stream); - stream.Dispose(); + workbook.SaveAs("Output.xlsx"); } {% endhighlight %}