Skip to content

Commit 6d1ea91

Browse files
authored
Merge pull request #256 from SyncfusionExamples/990137-CustomXmlSupportSample
990137-Modify file streams of C# [Cross-platform] in XlsIO UG
2 parents 42bf509 + 83a2e12 commit 6d1ea91

File tree

2 files changed

+5
-26
lines changed
  • Custom XML Support
    • Add Custom XML/.NET/Add Custom XML/Add Custom XML
    • Read Custom XML/.NET/Read Custom XML/Read Custom XML

2 files changed

+5
-26
lines changed

Custom XML Support/Add Custom XML/.NET/Add Custom XML/Add Custom XML/Program.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,10 @@ static void Main(string[] args)
2424

2525
#region Save
2626
//Saving the workbook
27-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/CreateCustomXML.xlsx"), FileMode.Create, FileAccess.Write);
28-
workbook.SaveAs(outputStream);
27+
workbook.SaveAs(Path.GetFullPath("Output/CreateCustomXML.xlsx"));
2928
#endregion
30-
31-
//Dispose streams
32-
outputStream.Dispose();
33-
3429
//Open default JSON
3530
}
3631
}
3732
}
38-
}
39-
40-
41-
42-
43-
33+
}

Custom XML Support/Read Custom XML/.NET/Read Custom XML/Read Custom XML/Program.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ static void Main(string[] args)
1212
{
1313
IApplication application = excelEngine.Excel;
1414
application.DefaultVersion = ExcelVersion.Xlsx;
15-
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
16-
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
15+
IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic);
1716
IWorksheet sheet = workbook.Worksheets[0];
1817

1918
//Access CustomXmlPart from Workbook
@@ -26,19 +25,9 @@ static void Main(string[] args)
2625

2726
#region Save
2827
//Saving the workbook
29-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/ReadXml.xlsx"), FileMode.Create, FileAccess.Write);
30-
workbook.SaveAs(outputStream);
28+
workbook.SaveAs(Path.GetFullPath("Output/ReadXml.xlsx"));
3129
#endregion
32-
33-
//Dispose streams
34-
outputStream.Dispose();
35-
inputStream.Dispose();
3630
}
3731
}
3832
}
39-
}
40-
41-
42-
43-
44-
33+
}

0 commit comments

Comments
 (0)