@@ -27,19 +27,13 @@ using (ExcelEngine excelEngine = new ExcelEngine())
2727{
2828 IApplication application = excelEngine.Excel;
2929 application.DefaultVersion = ExcelVersion.Xlsx;
30- FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.csv"), FileMode.Open, FileAccess.Read);
3130
3231 //Open the CSV file
33- IWorkbook workbook = application.Workbooks.Open(inputStream , ",");
32+ IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.csv") , ",");
3433 IWorksheet worksheet = workbook.Worksheets[0];
3534
36- //Saving the workbook as stream
37- FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
38- workbook.SaveAs(outputStream);
39-
40- //Dispose streams
41- outputStream.Dispose();
42- inputStream.Dispose();
35+ //Saving the workbook
36+ workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
4337}
4438{% endhighlight %}
4539
@@ -85,16 +79,10 @@ using (ExcelEngine excelEngine = new ExcelEngine())
8579 application.DefaultVersion = ExcelVersion.Xlsx;
8680
8781 //Open the TSV file
88- FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.tsv"), FileMode.Open, FileAccess.Read);
89- IWorkbook workbook = application.Workbooks.Open(inputStream, "\t");
82+ IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.tsv"), "\t");
9083
9184 //Save the workbook
92- FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.ReadWrite);
93- workbook.SaveAs(outputStream);
94-
95- //Dispose streams
96- outputStream.Dispose();
97- inputStream.Dispose();
85+ workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
9886}
9987{% endhighlight %}
10088
0 commit comments