diff --git a/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Color-Scales.md b/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Color-Scales.md index 6c96c9de5..49571a466 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Color-Scales.md +++ b/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Color-Scales.md @@ -18,8 +18,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]; //Create color scales for the data in specified range @@ -42,13 +41,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Data-Bars.md b/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Data-Bars.md index f42d94cf7..7f25b4838 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Data-Bars.md +++ b/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Data-Bars.md @@ -18,8 +18,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]; //Create data bars for the data in specified range @@ -36,13 +35,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Highlight-Cells.md b/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Highlight-Cells.md index 758c72b57..0ea20a787 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Highlight-Cells.md +++ b/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Highlight-Cells.md @@ -90,12 +90,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/UniqueandDuplicate.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/UniqueandDuplicate.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Icon-Sets.md b/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Icon-Sets.md index 5ce56b3e6..a276cbbee 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Icon-Sets.md +++ b/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Icon-Sets.md @@ -18,8 +18,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]; //Create icon sets for the data in specified range @@ -38,13 +37,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Top-Bottom.md b/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Top-Bottom.md index b7b5c0ca7..93a6c5935 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Top-Bottom.md +++ b/Document-Processing/Excel/Excel-Library/NET/Conditional-Formatting/Top-Bottom.md @@ -30,8 +30,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]; //Applying conditional formatting to "N6:N35". @@ -53,13 +52,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/TopToBottomRank.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/TopToBottomRank.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -189,8 +183,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]; //Applying conditional formatting to "N6:N35". @@ -215,13 +208,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 %} @@ -366,8 +354,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]; //Applying conditional formatting to "M6:M35" @@ -387,13 +374,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/AboveAndBelowAverage.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/AboveAndBelowAverage.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -469,8 +451,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]; //Applying conditional formatting to "M6:M35" @@ -493,13 +474,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/AboveAndBelowStandardDeviation.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/AboveAndBelowStandardDeviation.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Working-with-Conditional-Formatting.md b/Document-Processing/Excel/Excel-Library/NET/Working-with-Conditional-Formatting.md index baaf4fc6d..acf8c522a 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Working-with-Conditional-Formatting.md +++ b/Document-Processing/Excel/Excel-Library/NET/Working-with-Conditional-Formatting.md @@ -150,12 +150,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/ConditionalFormat.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/ConditionalFormat.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -297,16 +293,14 @@ 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]; //Read conditional formatting settings string formatType = worksheet.Range["A1"].ConditionalFormats[0].FormatType.ToString(); string cfOperator = worksheet.Range["A1"].ConditionalFormats[0].Operator.ToString(); - //Dispose streams - inputStream.Dispose(); + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} @@ -359,8 +353,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]; //Removing conditional format for a specified range @@ -368,13 +361,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/RemoveConditionalFormat.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/RemoveConditionalFormat.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -422,8 +410,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]; //Removing first conditional Format at the specified Range @@ -431,13 +418,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/RemoveConditionalFormat.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/RemoveConditionalFormat.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -483,8 +465,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]; //Removing Conditional Formatting Settings From Entire Sheet @@ -492,13 +473,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/RemoveAll.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/RemoveAll.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -557,12 +533,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/ConditionalFormat.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/ConditionalFormat.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %}