diff --git a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Appearance.md b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Appearance.md index ff3154d4e..61c8a532a 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Appearance.md +++ b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Appearance.md @@ -22,8 +22,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; IChart chart = worksheet.Charts[0]; @@ -50,13 +49,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) chartFillImpl2.FillType = ExcelFillType.SolidColor; chartFillImpl2.ForeColor = Color.FromArgb(143, 170, 220); ; - //Saving the workbook as streams - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} @@ -147,8 +141,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet worksheet = workbook.Worksheets[0]; IChart chart = worksheet.Charts[0]; @@ -183,13 +176,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) chartFillImpl2.ForeColor = Color.White; chartFillImpl2.Pattern = ExcelGradientPattern.Pat_5_Percent; - //Saving the workbook as stream - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} @@ -295,8 +283,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet worksheet = workbook.Worksheets[0]; IChart chart = worksheet.Charts[0]; @@ -337,13 +324,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) chartFillImpl2.GradientStops.Add(gradientStopImpl3); chartFillImpl2.GradientStops.Add(gradientStopImpl4); - //Saving the workbook as stream - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} @@ -460,8 +442,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; IChart chart = worksheet.Charts[0]; @@ -493,15 +474,12 @@ using (ExcelEngine excelEngine = new ExcelEngine()) serie1.SerieFormat.Fill.UserPicture(image2, "Image"); serie2.SerieFormat.Fill.UserPicture(image2, "Image"); - //Saving the workbook as stream - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); //Dispose streams - outputStream.Dispose(); imageStream1.Dispose(); imageStream2.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -587,8 +565,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet worksheet = workbook.Worksheets[0]; IChart chart = worksheet.Charts[0]; @@ -607,13 +584,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Set no fill to series serie1.SerieFormat.Fill.Visible = false; - //Saving the workbook as stream - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} @@ -979,12 +951,8 @@ The following code example illustrates how to apply 3D settings such as rotation #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Chart.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -1118,8 +1086,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; //Adding pie chart in the worksheet @@ -1146,13 +1113,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Chart.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -1218,8 +1180,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; //Adding chart in the workbook @@ -1244,13 +1205,10 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Chart.xlsx")); #endregion //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); imageStream.Dispose(); } {% endhighlight %} @@ -1371,12 +1329,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Chart.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Area.md b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Area.md index 09c5bb3ec..0ff07ed2d 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Area.md +++ b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Area.md @@ -86,8 +86,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet sheet = workbook.Worksheets[0]; IChartShape chart = sheet.Charts[0]; @@ -105,13 +104,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) chartArea.Fill.BackColor = Color.FromArgb(205, 217, 234); chartArea.Fill.ForeColor = Color.White; - //Saving the workbook as stream - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Axis.md b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Axis.md index ece58ec12..5360d2670 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Axis.md +++ b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Axis.md @@ -341,8 +341,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet sheet = workbook.Worksheets[0]; IChartShape chart = sheet.Charts[0]; @@ -410,13 +409,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Hiding minor gridlines chart.PrimaryValueAxis.HasMinorGridLines = false; - //Saving the workbook as stream - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Data-Labels.md b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Data-Labels.md index 792c0c949..c89c7d19e 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Data-Labels.md +++ b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Data-Labels.md @@ -158,8 +158,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; IChartShape chart = worksheet.Charts[0]; @@ -191,13 +190,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IChartDataLabels dataLabel = chart.Series[0].DataPoints.DefaultDataPoint.DataLabels; (dataLabel as ChartDataLabelsImpl).NumberFormat = "#,##0.00"; - //Saving the workbook as stream - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} @@ -345,12 +339,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs("Output.xlsx"); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Legend.md b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Legend.md index b557a5464..77b9880e6 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Legend.md +++ b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Legend.md @@ -228,8 +228,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; IChartShape chart = worksheet.Charts[0]; @@ -264,11 +263,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Set Legend without overlapping the chart chart.Legend.IncludeInLayout = true; - //Saving the workbook as stream - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(outputStream); - outputStream.Dispose(); - inputStream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Plot-Area.md b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Plot-Area.md index d20e5309f..e1c7a4b0f 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Plot-Area.md +++ b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Plot-Area.md @@ -130,8 +130,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet sheet = workbook.Worksheets[0]; IChartShape chart = sheet.Charts[0]; @@ -152,13 +151,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Set the position chartPlotArea.Layout.Left = 5; - //Saving the workbook as stream - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Series.md b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Series.md index 836698ed8..2b59fd6b4 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Series.md +++ b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Series.md @@ -151,8 +151,7 @@ using (ExcelEngine engine = new ExcelEngine()) { IApplication application = engine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet sheet = workbook.Worksheets[0]; //Create a Chart @@ -185,13 +184,8 @@ using (ExcelEngine engine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Chart.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Title.md b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Title.md index 692b1bebd..f12c4d0c1 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Title.md +++ b/Document-Processing/Excel/Excel-Library/NET/Charts/Chart-Title.md @@ -116,8 +116,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; IChartShape chart = sheet.Charts[0]; @@ -135,11 +134,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Manually resizing chart title area using Layout. chart.ChartTitleArea.Layout.Left = 20; - //Saving the workbook as stream - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(outputStream); - outputStream.Dispose(); - inputStream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Working-with-Charts.md b/Document-Processing/Excel/Excel-Library/NET/Working-with-Charts.md index a6ec7c680..910e5d646 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Working-with-Charts.md +++ b/Document-Processing/Excel/Excel-Library/NET/Working-with-Charts.md @@ -24,8 +24,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Create a Chart @@ -59,13 +58,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Chart.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -151,12 +145,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Chart.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -274,12 +264,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Chart.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -407,8 +393,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Add SparklineGroups @@ -426,13 +411,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Sparklines.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Sparklines.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -502,8 +482,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Edit Sparklines @@ -517,13 +496,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/EditSparklines.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/EditSparklines.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -579,8 +553,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; ISparklineGroup sparklineGroup = sheet.SparklineGroups[0]; @@ -597,13 +570,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/RemoveSparklines.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/RemoveSparklines.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -675,8 +643,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Create a chart @@ -702,13 +669,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Funnel.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Funnel.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -788,8 +750,7 @@ The following code example illustrates how to create Box and Whisker chart. { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Create a chart @@ -834,13 +795,8 @@ The following code example illustrates how to create Box and Whisker chart. #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/BoxandWhisker.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/BoxandWhisker.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -958,8 +914,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Create a chart @@ -988,13 +943,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Waterfall.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Waterfall.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -1088,8 +1038,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Create a chart @@ -1117,13 +1066,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Histogram.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Histogram.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -1215,8 +1159,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Create a chart @@ -1245,13 +1188,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Pareto.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Pareto.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -1346,8 +1284,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Create a chart @@ -1370,13 +1307,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Treemap.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Treemap.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -1458,8 +1390,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Create a chart @@ -1482,13 +1413,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Sunburst.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Sunburst.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -1651,12 +1577,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs("Output.xlsx"); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -1744,8 +1666,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx"), ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; IChartShape chart = sheet.Charts[0]; @@ -1754,13 +1675,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Chart.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %}