Skip to content

Commit 69c3258

Browse files
authored
Merge pull request #1631 from syncfusion-content/988874-ModifyStreams
988874-Modify file streams of C# [Cross-platform] in XlsIO UG
2 parents dd05c17 + 65b7b56 commit 69c3258

File tree

1 file changed

+14
-68
lines changed

1 file changed

+14
-68
lines changed

Document-Processing/Excel/Excel-Library/NET/Working-with-Cell-or-Range-Formatting.md

Lines changed: 14 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
3333

3434
#region Save
3535
//Saving the workbook
36-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/CreateStyle.xlsx"), FileMode.Create, FileAccess.Write);
37-
workbook.SaveAs(outputStream);
36+
workbook.SaveAs(Path.GetFullPath("Output/CreateStyle.xlsx"));
3837
#endregion
39-
40-
//Dispose streams
41-
outputStream.Dispose();
4238
}
4339
{% endhighlight %}
4440

@@ -110,12 +106,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
110106

111107
#region Save
112108
//Saving the workbook
113-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/RowColumnStyle.xlsx"), FileMode.Create, FileAccess.Write);
114-
workbook.SaveAs(outputStream);
109+
workbook.SaveAs(Path.GetFullPath("Output/RowColumnStyle.xlsx"));
115110
#endregion
116-
117-
//Dispose streams
118-
outputStream.Dispose();
119111
}
120112
{% endhighlight %}
121113

@@ -257,12 +249,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
257249

258250
#region Save
259251
//Saving the workbook
260-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/GlobalStyle.xlsx"), FileMode.Create, FileAccess.Write);
261-
workbook.SaveAs(outputStream);
252+
workbook.SaveAs(Path.GetFullPath("Output/GlobalStyle.xlsx"));
262253
#endregion
263-
264-
//Dispose streams
265-
outputStream.Dispose();
266254
}
267255
{% endhighlight %}
268256

@@ -687,12 +675,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
687675

688676
#region Save
689677
//Saving the workbook
690-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/NumberFormat.xlsx"), FileMode.Create, FileAccess.Write);
691-
workbook.SaveAs(outputStream);
678+
workbook.SaveAs(Path.GetFullPath("Output/NumberFormat.xlsx"));
692679
#endregion
693-
694-
//Dispose streams
695-
outputStream.Dispose();
696680
}
697681
{% endhighlight %}
698682

@@ -873,9 +857,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
873857
string text = worksheet.Range["B4"].DisplayText;
874858

875859
//Saving the workbook as stream
876-
FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite);
877-
workbook.SaveAs(stream);
878-
stream.Dispose();
860+
workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx"));
879861
}
880862
{% endhighlight %}
881863

@@ -970,12 +952,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
970952

971953
#region Save
972954
//Saving the workbook
973-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/HideCellContent.xlsx"), FileMode.Create, FileAccess.Write);
974-
workbook.SaveAs(outputStream);
955+
workbook.SaveAs(Path.GetFullPath("Output/HideCellContent.xlsx"));
975956
#endregion
976-
977-
//Dispose streams
978-
outputStream.Dispose();
979957
}
980958
{% endhighlight %}
981959

@@ -1189,12 +1167,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
11891167

11901168
#region Save
11911169
//Saving the workbook
1192-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Alignment.xlsx"), FileMode.Create, FileAccess.Write);
1193-
workbook.SaveAs(outputStream);
1170+
workbook.SaveAs(Path.GetFullPath("Output/Alignment.xlsx"));
11941171
#endregion
1195-
1196-
//Dispose streams
1197-
outputStream.Dispose();
11981172
}
11991173
{% endhighlight %}
12001174

@@ -1374,12 +1348,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
13741348

13751349
#region Save
13761350
//Saving the workbook
1377-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/MergeandUnMerge.xlsx"), FileMode.Create, FileAccess.Write);
1378-
workbook.SaveAs(outputStream);
1351+
workbook.SaveAs(Path.GetFullPath("Output/MergeandUnMerge.xlsx"));
13791352
#endregion
1380-
1381-
//Dispose streams
1382-
outputStream.Dispose();
13831353
}
13841354
{% endhighlight %}
13851355

@@ -1445,12 +1415,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
14451415

14461416
#region Save
14471417
//Saving the workbook
1448-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/WrapText.xlsx"), FileMode.Create, FileAccess.Write);
1449-
workbook.SaveAs(outputStream);
1418+
workbook.SaveAs(Path.GetFullPath("Output/WrapText.xlsx"));
14501419
#endregion
1451-
1452-
//Dispose streams
1453-
outputStream.Dispose();
14541420
}
14551421
{% endhighlight %}
14561422

@@ -1542,12 +1508,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
15421508

15431509
#region Save
15441510
//Saving the workbook
1545-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/AutoFit.xlsx"), FileMode.Create, FileAccess.Write);
1546-
workbook.SaveAs(outputStream);
1511+
workbook.SaveAs(Path.GetFullPath("Output/AutoFit.xlsx"));
15471512
#endregion
1548-
1549-
//Dispose streams
1550-
outputStream.Dispose();
15511513
}
15521514
{% endhighlight %}
15531515

@@ -1643,12 +1605,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
16431605

16441606
#region Save
16451607
//Saving the workbook
1646-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/FontSettings.xlsx"), FileMode.Create, FileAccess.Write);
1647-
workbook.SaveAs(outputStream);
1608+
workbook.SaveAs(Path.GetFullPath("Output/FontSettings.xlsx"));
16481609
#endregion
1649-
1650-
//Dispose streams
1651-
outputStream.Dispose();
16521610
}
16531611
{% endhighlight %}
16541612

@@ -1860,12 +1818,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
18601818

18611819
#region Save
18621820
//Saving the workbook
1863-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/BorderSettings.xlsx"), FileMode.Create, FileAccess.Write);
1864-
workbook.SaveAs(outputStream);
1821+
workbook.SaveAs(Path.GetFullPath("Output/BorderSettings.xlsx"));
18651822
#endregion
1866-
1867-
//Dispose streams
1868-
outputStream.Dispose();
18691823
}
18701824
{% endhighlight %}
18711825

@@ -1996,12 +1950,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
19961950

19971951
#region Save
19981952
//Saving the workbook
1999-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/HTMLString.xlsx"), FileMode.Create, FileAccess.Write);
2000-
workbook.SaveAs(outputStream);
1953+
workbook.SaveAs(Path.GetFullPath("Output/HTMLString.xlsx"));
20011954
#endregion
2002-
2003-
//Dispose streams
2004-
outputStream.Dispose();
20051955
}
20061956
{% endhighlight %}
20071957

@@ -2105,12 +2055,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
21052055

21062056
#region Save
21072057
//Saving the workbook
2108-
FileStream outputStream = new FileStream(Path.GetFullPath("Output/RichText.xlsx"), FileMode.Create, FileAccess.Write);
2109-
workbook.SaveAs(outputStream);
2058+
workbook.SaveAs(Path.GetFullPath("Output/RichText.xlsx"));
21102059
#endregion
2111-
2112-
//Dispose streams
2113-
outputStream.Dispose();
21142060
}
21152061
{% endhighlight %}
21162062

0 commit comments

Comments
 (0)