@@ -22,8 +22,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
2222{
2323	IApplication application = excelEngine.Excel;
2424	application.DefaultVersion = ExcelVersion.Xlsx;
25- 	FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
26- 	IWorkbook workbook = application.Workbooks.Open(inputStream);
25+ 	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
2726	IWorksheet worksheet = workbook.Worksheets[ 0] ;
2827	IChart chart = worksheet.Charts[ 0] ;
2928
@@ -50,13 +49,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
5049	chartFillImpl2.FillType = ExcelFillType.SolidColor; 
5150	chartFillImpl2.ForeColor = Color.FromArgb(143, 170, 220); ; 
5251
53- 	//Saving the workbook as streams 
54- 	FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); 
55- 	workbook.SaveAs(outputStream); 
56- 
57- 	//Dispose streams 
58- 	outputStream.Dispose(); 
59- 	inputStream.Dispose(); 
52+ 	//Saving the workbook 
53+ 	workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); 
6054}
6155{% endhighlight %}
6256
@@ -147,8 +141,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
147141{
148142	IApplication application = excelEngine.Excel;
149143	application.DefaultVersion = ExcelVersion.Xlsx;
150- 	FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
151- 	IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
144+ 	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic);
152145	IWorksheet worksheet = workbook.Worksheets[ 0] ;
153146	IChart chart = worksheet.Charts[ 0] ;
154147
@@ -183,13 +176,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
183176	chartFillImpl2.ForeColor = Color.White; 
184177	chartFillImpl2.Pattern = ExcelGradientPattern.Pat_5_Percent; 
185178
186- 	//Saving the workbook as stream 
187- 	FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); 
188- 	workbook.SaveAs(outputStream); 
189- 
190- 	//Dispose streams 
191- 	outputStream.Dispose(); 
192- 	inputStream.Dispose(); 
179+ 	//Saving the workbook 
180+ 	workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); 
193181}
194182{% endhighlight %}
195183
@@ -295,8 +283,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
295283{
296284	IApplication application = excelEngine.Excel;
297285	application.DefaultVersion = ExcelVersion.Xlsx;
298- 	FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
299- 	IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
286+ 	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic);
300287	IWorksheet worksheet = workbook.Worksheets[ 0] ;
301288	IChart chart = worksheet.Charts[ 0] ;
302289
@@ -337,13 +324,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
337324	chartFillImpl2.GradientStops.Add(gradientStopImpl3); 
338325	chartFillImpl2.GradientStops.Add(gradientStopImpl4); 
339326
340- 	//Saving the workbook as stream 
341- 	FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); 
342- 	workbook.SaveAs(outputStream); 
343- 
344- 	//Dispose streams 
345- 	outputStream.Dispose(); 
346- 	inputStream.Dispose(); 
327+ 	//Saving the workbook  
328+ 	workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); 
347329}
348330{% endhighlight %}
349331
@@ -460,8 +442,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
460442{
461443	IApplication application = excelEngine.Excel;
462444	application.DefaultVersion = ExcelVersion.Xlsx;
463- 	FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
464- 	IWorkbook workbook = application.Workbooks.Open(inputStream);
445+ 	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
465446	IWorksheet worksheet = workbook.Worksheets[ 0] ;
466447	IChart chart = worksheet.Charts[ 0] ;
467448
@@ -493,15 +474,12 @@ using (ExcelEngine excelEngine = new ExcelEngine())
493474	serie1.SerieFormat.Fill.UserPicture(image2, "Image"); 
494475	serie2.SerieFormat.Fill.UserPicture(image2, "Image"); 
495476
496- 	//Saving the workbook as stream 
497- 	FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); 
498- 	workbook.SaveAs(outputStream); 
477+ 	//Saving the workbook 
478+ 	workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); 
499479
500480	//Dispose streams 
501- 	outputStream.Dispose(); 
502481	imageStream1.Dispose(); 
503482	imageStream2.Dispose(); 
504- 	inputStream.Dispose(); 
505483}
506484{% endhighlight %}
507485
@@ -587,8 +565,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
587565{
588566	IApplication application = excelEngine.Excel;
589567	application.DefaultVersion = ExcelVersion.Xlsx;
590- 	FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
591- 	IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
568+ 	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic);
592569	IWorksheet worksheet = workbook.Worksheets[ 0] ;
593570	IChart chart = worksheet.Charts[ 0] ;
594571
@@ -607,13 +584,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
607584	//Set no fill to series 
608585	serie1.SerieFormat.Fill.Visible = false; 
609586
610- 	//Saving the workbook as stream 
611- 	FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); 
612- 	workbook.SaveAs(outputStream); 
613- 
614- 	//Dispose streams 
615- 	outputStream.Dispose(); 
616- 	inputStream.Dispose(); 
587+ 	//Saving the workbook  
588+ 	workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); 
617589}
618590{% endhighlight %}
619591
@@ -979,12 +951,8 @@ The following code example illustrates how to apply 3D settings such as rotation
979951
980952	#region Save 
981953	//Saving the workbook 
982- 	FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write); 
983- 	workbook.SaveAs(outputStream); 
954+ 	workbook.SaveAs(Path.GetFullPath("Output/Chart.xlsx")); 
984955	#endregion 
985- 
986- 	//Dispose streams 
987- 	outputStream.Dispose(); 
988956}
989957{% endhighlight %}
990958
@@ -1118,8 +1086,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
11181086{
11191087	IApplication application = excelEngine.Excel;
11201088	application.DefaultVersion = ExcelVersion.Xlsx;
1121- 	FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
1122- 	IWorkbook workbook = application.Workbooks.Open(inputStream);
1089+ 	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
11231090	IWorksheet worksheet = workbook.Worksheets[ 0] ;
11241091
11251092	//Adding pie chart in the worksheet 
@@ -1146,13 +1113,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
11461113
11471114	#region Save 
11481115	//Saving the workbook 
1149- 	FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write); 
1150- 	workbook.SaveAs(outputStream); 
1116+ 	workbook.SaveAs(Path.GetFullPath("Output/Chart.xlsx")); 
11511117	#endregion 
1152- 
1153- 	//Dispose streams 
1154- 	outputStream.Dispose(); 
1155- 	inputStream.Dispose(); 
11561118}
11571119{% endhighlight %}
11581120
@@ -1218,8 +1180,7 @@ using (ExcelEngine excelEngine = new ExcelEngine())
12181180{
12191181	IApplication application = excelEngine.Excel;
12201182	application.DefaultVersion = ExcelVersion.Xlsx;
1221- 	FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
1222- 	IWorkbook workbook = application.Workbooks.Open(inputStream);
1183+ 	IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"));
12231184	IWorksheet worksheet = workbook.Worksheets[ 0] ;
12241185
12251186	//Adding chart in the workbook 
@@ -1244,13 +1205,10 @@ using (ExcelEngine excelEngine = new ExcelEngine())
12441205
12451206	#region Save 
12461207	//Saving the workbook 
1247- 	FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write); 
1248- 	workbook.SaveAs(outputStream); 
1208+ 	workbook.SaveAs(Path.GetFullPath("Output/Chart.xlsx")); 
12491209	#endregion 
12501210
12511211	//Dispose streams 
1252- 	outputStream.Dispose(); 
1253- 	inputStream.Dispose(); 
12541212	imageStream.Dispose(); 
12551213}
12561214{% endhighlight %}
@@ -1371,12 +1329,8 @@ using (ExcelEngine excelEngine = new ExcelEngine())
13711329
13721330	#region Save 
13731331	//Saving the workbook 
1374- 	FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write); 
1375- 	workbook.SaveAs(outputStream); 
1332+ 	workbook.SaveAs(Path.GetFullPath("Output/Chart.xlsx")); 
13761333	#endregion 
1377- 
1378- 	//Dispose streams 
1379- 	outputStream.Dispose(); 
13801334}
13811335{% endhighlight %}
13821336
0 commit comments