From 986f931b9c0a8423bbd472973bb624d867942a43 Mon Sep 17 00:00:00 2001 From: KarthikaSF4773 Date: Tue, 28 Oct 2025 17:58:54 +0530 Subject: [PATCH] 988804-ModifyStreamsSamples --- .../.NET/Add Total Row/Add Total Row/Program.cs | 10 ++-------- .../Apply Custom Style/Apply Custom Style/Program.cs | 6 +----- .../.NET/Create Table/Create Table/Program.cs | 10 ++-------- .../.NET/Format Table/Format Table/Program.cs | 10 ++-------- .../.NET/Insert Column/Insert Column/Program.cs | 10 ++-------- .../Read Table/.NET/Read Table/Read Table/Program.cs | 10 ++-------- .../.NET/Remove Column/Remove Column/Program.cs | 10 ++-------- 7 files changed, 13 insertions(+), 53 deletions(-) diff --git a/Create and Edit Table/Add Total Row/.NET/Add Total Row/Add Total Row/Program.cs b/Create and Edit Table/Add Total Row/.NET/Add Total Row/Add Total Row/Program.cs index c8d471b2..f281e443 100644 --- a/Create and Edit Table/Add Total Row/.NET/Add Total Row/Add Total Row/Program.cs +++ b/Create and Edit Table/Add Total Row/.NET/Add Total Row/Add Total Row/Program.cs @@ -12,8 +12,7 @@ static void Main(string[] args) { 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]; //Creating a table @@ -27,13 +26,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/AddTotalRow.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/AddTotalRow.xlsx")); #endregion - - //Dispose streams - inputStream.Dispose(); - outputStream.Dispose(); } } } diff --git a/Create and Edit Table/Apply Custom Style/.NET/Apply Custom Style/Apply Custom Style/Program.cs b/Create and Edit Table/Apply Custom Style/.NET/Apply Custom Style/Apply Custom Style/Program.cs index 5a8e1916..8146295c 100644 --- a/Create and Edit Table/Apply Custom Style/.NET/Apply Custom Style/Apply Custom Style/Program.cs +++ b/Create and Edit Table/Apply Custom Style/.NET/Apply Custom Style/Apply Custom Style/Program.cs @@ -100,12 +100,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/CustomTableStyle.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/CustomTableStyle.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } } } diff --git a/Create and Edit Table/Create Table/.NET/Create Table/Create Table/Program.cs b/Create and Edit Table/Create Table/.NET/Create Table/Create Table/Program.cs index 8e7f85c2..72c5a1a9 100644 --- a/Create and Edit Table/Create Table/.NET/Create Table/Create Table/Program.cs +++ b/Create and Edit Table/Create Table/.NET/Create Table/Create Table/Program.cs @@ -12,8 +12,7 @@ static void Main(string[] args) { 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]; //Create for the given data @@ -21,13 +20,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/CreateTable.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/CreateTable.xlsx")); #endregion - - //Dispose streams - inputStream.Dispose(); - outputStream.Dispose(); } } } diff --git a/Create and Edit Table/Format Table/.NET/Format Table/Format Table/Program.cs b/Create and Edit Table/Format Table/.NET/Format Table/Format Table/Program.cs index 301634b4..206ef037 100644 --- a/Create and Edit Table/Format Table/.NET/Format Table/Format Table/Program.cs +++ b/Create and Edit Table/Format Table/.NET/Format Table/Format Table/Program.cs @@ -12,8 +12,7 @@ static void Main(string[] args) { 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]; //Creating a table @@ -24,13 +23,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/FormatTable.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/FormatTable.xlsx")); #endregion - - //Dispose streams - inputStream.Dispose(); - outputStream.Dispose(); } } } diff --git a/Create and Edit Table/Insert Column/.NET/Insert Column/Insert Column/Program.cs b/Create and Edit Table/Insert Column/.NET/Insert Column/Insert Column/Program.cs index 3aca0bf2..222853f8 100644 --- a/Create and Edit Table/Insert Column/.NET/Insert Column/Insert Column/Program.cs +++ b/Create and Edit Table/Insert Column/.NET/Insert Column/Insert Column/Program.cs @@ -12,8 +12,7 @@ static void Main(string[] args) { 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]; //Creating a table @@ -24,13 +23,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/InsertTableColumn.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/InsertTableColumn.xlsx")); #endregion - - //Dispose streams - inputStream.Dispose(); - outputStream.Dispose(); } } } diff --git a/Create and Edit Table/Read Table/.NET/Read Table/Read Table/Program.cs b/Create and Edit Table/Read Table/.NET/Read Table/Read Table/Program.cs index b7970a1b..2355c719 100644 --- a/Create and Edit Table/Read Table/.NET/Read Table/Read Table/Program.cs +++ b/Create and Edit Table/Read Table/.NET/Read Table/Read Table/Program.cs @@ -12,8 +12,7 @@ static void Main(string[] args) { 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]; //Accessing first table in the sheet @@ -24,13 +23,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/ReadTable.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/ReadTable.xlsx")); #endregion - - //Dispose streams - inputStream.Dispose(); - outputStream.Dispose(); } } } diff --git a/Create and Edit Table/Remove Column/.NET/Remove Column/Remove Column/Program.cs b/Create and Edit Table/Remove Column/.NET/Remove Column/Remove Column/Program.cs index c5ecb59a..4b0ee4ef 100644 --- a/Create and Edit Table/Remove Column/.NET/Remove Column/Remove Column/Program.cs +++ b/Create and Edit Table/Remove Column/.NET/Remove Column/Remove Column/Program.cs @@ -12,8 +12,7 @@ static void Main(string[] args) { 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]; //Creating a table @@ -24,13 +23,8 @@ static void Main(string[] args) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/RemoveTableColumn.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/RemoveTableColumn.xlsx")); #endregion - - //Dispose streams - inputStream.Dispose(); - outputStream.Dispose(); } } }