Skip to content

Commit f1145d1

Browse files
authored
Merge pull request #1706 from syncfusion-content/990137-CustomXmlSupport
990137-Modify file streams of C# [Cross-platform] in XlsIO UG
2 parents 6fc32c7 + 5c45129 commit f1145d1

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

Document-Processing/Excel/Excel-Library/NET/Custom-XML-Support.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)