From 65bf347c0569cb1233abd4821d2f025176348c2f Mon Sep 17 00:00:00 2001 From: KarthikaSF4773 Date: Mon, 6 Oct 2025 23:48:53 +0530 Subject: [PATCH 1/2] 985509-ModifyStreams --- .../NET/Working-with-Excel-Worksheet.md | 42 ++---- .../Excel-Library/NET/Worksheet/Auto-Fill.md | 8 +- .../NET/Worksheet/Fill-Series.md | 18 +-- .../NET/Worksheet/Freeze-Panes.md | 42 ++---- .../NET/Worksheet/Move-or-Copy.md | 120 +++++------------- .../NET/Worksheet/Page-Setup-Options.md | 66 ++-------- .../NET/Worksheet/Show-or-Hide.md | 54 ++------ 7 files changed, 76 insertions(+), 274 deletions(-) diff --git a/Document-Processing/Excel/Excel-Library/NET/Working-with-Excel-Worksheet.md b/Document-Processing/Excel/Excel-Library/NET/Working-with-Excel-Worksheet.md index 35af3bc58..7fd582a87 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Working-with-Excel-Worksheet.md +++ b/Document-Processing/Excel/Excel-Library/NET/Working-with-Excel-Worksheet.md @@ -35,12 +35,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/CreateWorksheet.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/CreateWorksheet.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -95,8 +91,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")); #region Access //Accessing via index @@ -105,9 +100,6 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Accessing via sheet name IWorksheet NamedSheet = workbook.Worksheets["Sample"]; #endregion - - //Dispose streams - inputStream.Dispose(); } {% endhighlight %} @@ -173,8 +165,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")); #region Remove //Removing the sheet @@ -183,13 +174,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/RemoveWorksheet.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/RemoveWorksheet.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} @@ -239,12 +225,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Set sheet name worksheet.Name = "Sample"; - //Saving the workbook as stream - FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(stream); - - //Dispose streams - stream.Dispose(); + //Saving the workbook + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} @@ -304,12 +286,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/HighlightSheetTab.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/HighlightSheetTab.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -395,12 +373,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/ActivateWorksheet.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/ActivateWorksheet.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Auto-Fill.md b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Auto-Fill.md index 638ce5f10..6fbb3e64a 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Auto-Fill.md +++ b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Auto-Fill.md @@ -323,12 +323,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Auto fill using the series option source.AutoFill(destinationRange, ExcelAutoFillType.FillSeries); - //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Fill-Series.md b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Fill-Series.md index 3c63338c6..e398873a2 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Fill-Series.md +++ b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Fill-Series.md @@ -163,11 +163,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) range.FillSeries(ExcelSeriesBy.Columns, ExcelFillSeries.Years, 2, new DateTime(2100, 1, 1)); //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} @@ -244,11 +240,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) range.FillSeries(ExcelSeriesBy.Columns, ExcelFillSeries.Linear, 5, 1000); //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} @@ -327,11 +319,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) range.FillSeries(ExcelSeriesBy.Columns, ExcelFillSeries.Linear, true); //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Freeze-Panes.md b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Freeze-Panes.md index 6e0e08f62..377a780dd 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Freeze-Panes.md +++ b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Freeze-Panes.md @@ -26,8 +26,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 freeze rows to the sheet by specifying a cell @@ -36,13 +35,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Set first visible row in the bottom pane worksheet.FirstVisibleRow = 3; - //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 %} @@ -96,8 +90,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 freeze columns to the sheet by specifying a cell @@ -106,13 +99,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Set first visible column in the right pane worksheet.FirstVisibleColumn = 4; - //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 %} @@ -168,20 +156,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); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; //Unfreeze panes in the worksheet worksheet.RemovePanes(); - //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 %} @@ -246,12 +228,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/SplitPanes.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/SplitPanes.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Move-or-Copy.md b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Move-or-Copy.md index 70b71eb6e..c088093f9 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Move-or-Copy.md +++ b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Move-or-Copy.md @@ -22,22 +22,14 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream sourceStream = new FileStream(Path.GetFullPath(@"Data/SourceWorkbookTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook sourceWorkbook = application.Workbooks.Open(sourceStream); - FileStream destinationStream = new FileStream(Path.GetFullPath(@"Data/DestinationWorkbookTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook destinationWorkbook = application.Workbooks.Open(destinationStream); + IWorkbook sourceWorkbook = application.Workbooks.Open(Path.GetFullPath(@"Data/SourceWorkbookTemplate.xlsx")); + IWorkbook destinationWorkbook = application.Workbooks.Open(Path.GetFullPath(@"Data/DestinationWorkbookTemplate.xlsx")); //Clone the workbook destinationWorkbook = sourceWorkbook.Clone(); - //Saving the workbook as stream - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - destinationWorkbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); - destinationStream.Dispose(); - sourceStream.Dispose(); + //Saving the workbook + destinationWorkbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} @@ -87,11 +79,9 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream sourceStream = new FileStream(Path.GetFullPath(@"Data/SourceTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook sourceWorkbook = application.Workbooks.Open(sourceStream); + IWorkbook sourceWorkbook = application.Workbooks.Open(Path.GetFullPath(@"Data/SourceTemplate.xlsx")); - FileStream destinationStream = new FileStream(Path.GetFullPath(@"Data/DestinationTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook destinationWorkbook = application.Workbooks.Open(destinationStream); + IWorkbook destinationWorkbook = application.Workbooks.Open(Path.GetFullPath(@"Data/DestinationTemplate.xlsx")); #region Copy Worksheet //Copy first worksheet from the source workbook to the destination workbook @@ -101,14 +91,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/CopyWorksheet.xlsx"), FileMode.Create, FileAccess.Write); - destinationWorkbook.SaveAs(outputStream); + destinationWorkbook.SaveAs(Path.GetFullPath("Output/CopyWorksheet.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - destinationStream.Dispose(); - sourceStream.Dispose(); } {% endhighlight %} @@ -159,8 +143,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 sourceWorksheet = workbook.Worksheets[0]; IWorksheet destinationWorksheet = workbook.Worksheets[1]; @@ -171,13 +154,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Copy the entire row to the next sheet sourceRow.EntireRow.CopyTo(destinationRow); - //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 %} @@ -236,8 +214,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 sourceWorksheet = workbook.Worksheets[0]; IWorksheet destinationWorksheet = workbook.Worksheets[1]; @@ -248,13 +225,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Copy the entire column to the next sheet sourceColumn.EntireColumn.CopyTo(destinationColumn); - //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 %} @@ -314,8 +286,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream sourceStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(sourceStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet sourceWorksheet = workbook.Worksheets[0]; IWorksheet destinationWorksheet = workbook.Worksheets[1]; @@ -326,13 +297,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Copy the cell range to the next sheet source.CopyTo(destination); - //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(); - sourceStream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} @@ -392,8 +358,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("../../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet sourceWorksheet = workbook.Worksheets[0]; IWorksheet destinationWorksheet = workbook.Worksheets[1]; @@ -404,13 +369,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Copy the cell range with options source.CopyTo(destination, ExcelCopyRangeOptions.CopyStyles); - //Saving the workbook as stream - FileStream outputStream = new FileStream("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 %} @@ -476,10 +436,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Move the Sheet sheet.Move(1); - //Saving the workbook as stream - FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(stream); - stream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} @@ -527,8 +485,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream sourceStream = new FileStream("../../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(sourceStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet sourceWorksheet = workbook.Worksheets[0]; IWorksheet destinationWorksheet = workbook.Worksheets[1]; @@ -539,13 +496,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Move the entire row to the next sheet sourceRow.EntireRow.MoveTo(destinationRow); - //Saving the workbook as stream - FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); - sourceStream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} @@ -603,8 +555,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("../../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream ); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet sourceWorksheet = workbook.Worksheets[0]; IWorksheet destinationWorksheet = workbook.Worksheets[1]; @@ -615,13 +566,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Move the entire column to the next sheet source.EntireColumn.MoveTo(destination); - //Saving the workbook as stream - FileStream outputStream = new FileStream("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 %} @@ -679,8 +625,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("../../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); IWorksheet sourceWorksheet = workbook.Worksheets[0]; IWorksheet destinationWorksheet = workbook.Worksheets[1]; @@ -691,13 +636,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Move the cell range to the next sheet source.MoveTo(destination); - //Saving the workbook as stream - FileStream outputStream = new FileStream("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 %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Page-Setup-Options.md b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Page-Setup-Options.md index 947905787..d40832e00 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Page-Setup-Options.md +++ b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Page-Setup-Options.md @@ -40,12 +40,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/FitToPagesTall.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/FitToPagesTall.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -131,12 +127,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/FitToPagesWide.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/FitToPagesWide.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -221,12 +213,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/IsFitToPage.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/IsFitToPage.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -312,12 +300,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/SummaryColumnRight.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/SummaryColumnRight.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -409,12 +393,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/SummaryRowBelow.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/SummaryRowBelow.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -504,12 +484,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/PrintArea.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/PrintArea.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -592,12 +568,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/PrintGridlines.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/PrintGridlines.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -680,12 +652,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/PrintHeadings.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/PrintHeadings.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -768,12 +736,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/PrintTitleColumns.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/PrintTitleColumns.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -857,12 +821,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/PrintTitleRows.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/PrintTitleRows.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -950,10 +910,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Adding the file name to the right footer with blue color formatting worksheet.PageSetup.RightFooter = "&K0000FF&F"; - //Saving the workbook as stream - FileStream stream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create); - workbook.SaveAs(stream); - stream.Dispose(); + //Saving the workbook + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Show-or-Hide.md b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Show-or-Hide.md index aed72e4b3..a07286bc6 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Show-or-Hide.md +++ b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Show-or-Hide.md @@ -18,21 +18,15 @@ 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]; //Show row and column worksheet.ShowRow(2, true); worksheet.ShowColumn(2, true); - //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 %} @@ -82,21 +76,15 @@ 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]; //Hide row and column worksheet.HideRow(2); worksheet.HideColumn(2); - //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 %} @@ -158,12 +146,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/HideWorksheet.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/HideWorksheet.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -224,12 +208,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/HideGridlines.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/HideGridlines.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -290,12 +270,8 @@ The following code example illustrates how to hide the row and column headings u #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/HideRowandColumnHeaders.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/HideRowandColumnHeaders.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -354,12 +330,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/HideWorksheetTabs.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/HideWorksheetTabs.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -424,12 +396,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/SetZoomLevel.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/SetZoomLevel.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} From 56e0cd6f3e500d93ec74fdda2a68b356438adb04 Mon Sep 17 00:00:00 2001 From: KarthikaSF4773 Date: Tue, 14 Oct 2025 23:49:48 +0530 Subject: [PATCH 2/2] 985509-ModifyStreams --- .../Excel/Excel-Library/NET/Worksheet/Auto-Fill.md | 2 +- .../Excel/Excel-Library/NET/Worksheet/Fill-Series.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Auto-Fill.md b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Auto-Fill.md index 6fbb3e64a..360a31fe7 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Auto-Fill.md +++ b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Auto-Fill.md @@ -6,7 +6,7 @@ control: XlsIO documentation: UG --- -# Auto Fill +# Auto Fill Feature in Excel Document The **Auto Fill** enables users to programmatically populate a range of Excel cells based on defined patterns, sequences, or trends. This helps reduce manual data entry by automatically generating values using built-in logic. diff --git a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Fill-Series.md b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Fill-Series.md index e398873a2..2772e1296 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Worksheet/Fill-Series.md +++ b/Document-Processing/Excel/Excel-Library/NET/Worksheet/Fill-Series.md @@ -6,7 +6,7 @@ control: XlsIO documentation: UG --- -# Fill Series +# Fill Series Feature in Excel Document The **Fill Series** feature in the XlsIO library allows users to programmatically fill a range with a sequence of values based on the specified direction (row or column), series type, step value, and stop value.