Skip to content

Commit 7424c5d

Browse files
authored
Merge pull request #1697 from syncfusion-content/990137-SlicerUG
990137-Modify file streams of C# [Cross-platform] in XlsIO UG
2 parents 6c73f48 + 252adb6 commit 7424c5d

File tree

1 file changed

+4
-10
lines changed
  • Document-Processing/Excel/Excel-Library/NET

1 file changed

+4
-10
lines changed

Document-Processing/Excel/Excel-Library/NET/Slicer.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
2525
{
2626
IApplication application = excelEngine.Excel;
2727
application.DefaultVersion = ExcelVersion.Xlsx;
28-
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
29-
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
28+
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
3029
IWorksheet sheet = workbook.Worksheets[0];
3130

3231
//Access the table.
@@ -35,9 +34,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
3534
//Add slicer for the table.
3635
sheet.Slicers.Add(table, 3, 11, 2);
3736

38-
FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite);
39-
workbook.SaveAs(stream);
40-
stream.Dispose();
37+
workbook.SaveAs("Output.xlsx");
4138
}
4239
{% endhighlight %}
4340

@@ -266,8 +263,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
266263
{
267264
IApplication application = excelEngine.Excel;
268265
application.DefaultVersion = ExcelVersion.Xlsx;
269-
FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
270-
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
266+
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
271267
IWorksheet sheet = workbook.Worksheets[0];
272268

273269
//Access the table
@@ -306,9 +302,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
306302
//Slicer style
307303
slicer.SlicerStyle = ExcelSlicerStyle.SlicerStyleDark2;
308304

309-
FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite);
310-
workbook.SaveAs(stream);
311-
stream.Dispose();
305+
workbook.SaveAs("Output.xlsx");
312306
}
313307
{% endhighlight %}
314308

0 commit comments

Comments
 (0)