@@ -38,13 +38,9 @@ using (ExcelEngine excelEngine = new ExcelEngine())
3838
3939 #region Save
4040 //Saving the workbook
41- FileStream outputStream = new FileStream(Path.GetFullPath("Output/CreateCustomXML.xlsx"), FileMode.Create, FileAccess.Write);
42- workbook.SaveAs(outputStream);
41+ workbook.SaveAs(Path.GetFullPath("Output/CreateCustomXML.xlsx"));
4342 #endregion
4443
45- //Dispose streams
46- outputStream.Dispose();
47-
4844 //Open default JSON
4945}
5046{% endhighlight %}
@@ -99,8 +95,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
9995{
10096 IApplication application = excelEngine.Excel;
10197 application.DefaultVersion = ExcelVersion.Xlsx;
102- FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
103- IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
98+ IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic);
10499 IWorksheet sheet = workbook.Worksheets[ 0] ;
105100
106101 //Access CustomXmlPart from Workbook
@@ -113,13 +108,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
113108
114109 #region Save
115110 //Saving the workbook
116- FileStream outputStream = new FileStream(Path.GetFullPath("Output/ReadXml.xlsx"), FileMode.Create, FileAccess.Write);
117- workbook.SaveAs(outputStream);
111+ workbook.SaveAs(Path.GetFullPath("Output/ReadXml.xlsx"));
118112 #endregion
119-
120- //Dispose streams
121- outputStream.Dispose();
122- inputStream.Dispose();
123113}
124114{% endhighlight %}
125115
0 commit comments