From ddc7e599afd8825e0748e842ce3ffb9f8cee3768 Mon Sep 17 00:00:00 2001 From: Ramya Sivakumar Date: Fri, 17 Oct 2025 19:01:00 +0530 Subject: [PATCH 1/5] UG documentation 978280: FAQ for how to get the column width and row height in pixels --- ...e-column-width-and-row-height-in-pixels.md | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-the-column-width-and-row-height-in-pixels.md diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-the-column-width-and-row-height-in-pixels.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-the-column-width-and-row-height-in-pixels.md new file mode 100644 index 000000000..36ab7fabc --- /dev/null +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-the-column-width-and-row-height-in-pixels.md @@ -0,0 +1,87 @@ +--- +title: How to get the column width and row height in pixels | Syncfusion +description: Code example showing how to retrieve column width and row height in pixels using the Syncfusion .NET Excel library (XlsIO). +platform: document-processing +control: XlsIO +documentation: UG +--- + +# How to get the column width and row height in pixels? + +In Essential® XlsIO, you can obtain column widths and row heights in pixels by using the [GetColumnWidthInPixels](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_GetColumnWidthInPixels_System_Int32_) and [GetRowHeightInPixels](https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_GetRowHeightInPixels_System_Int32_) methods. The below code snippet demonstrates this. + +{% tabs %} +{% highlight c# tabtitle="C# [Cross-platform]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + FileStream inputStream = new FileStream("InputTemplate.xlsx", FileMode.Open, FileAccess.Read); + IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorksheet worksheet = workbook.Worksheets[0]; + + var range = worksheet.UsedRange["A1"]; + + //Get the Column width in pixels + var width = worksheet.GetColumnWidthInPixels(range.Column); + + //Get the Row height in pixels + var height = worksheet.GetRowHeightInPixels(range.Row); + + #region Save + //Saving the workbook + FileStream outputStream = new FileStream("RowsandColumns.xlsx", FileMode.Create, FileAccess.Write); + workbook.SaveAs(outputStream); + #endregion + + //Dispose streams + outputStream.Dispose(); + inputStream.Dispose(); +} +{% endhighlight %} + +{% highlight c# tabtitle="C# [Windows-specific]" %} +using (ExcelEngine excelEngine = new ExcelEngine()) +{ + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); + IWorksheet worksheet = workbook.Worksheets[0]; + var range = worksheet.UsedRange["A1"]; + + //Get the Column width in pixels + var width = worksheet.GetColumnWidthInPixels(range.Column); + + //Get the Row height in pixels + var height = worksheet.GetRowHeightInPixels(range.Row); + + workbook.SaveAs("RowsandColumns.xlsx"); +} +{% endhighlight %} + +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} + Using excelEngine As ExcelEngine = New ExcelEngine() + Dim application As IApplication = excelEngine.Excel + application.DefaultVersion = ExcelVersion.Excel2013 + Dim workbook As IWorkbook = application.Workbooks.Open("InputTemplate.xlsx", ExcelOpenType.Automatic) + Dim worksheet As IWorksheet = workbook.Worksheets(0) + + Dim range = worksheet.UsedRange("A1") + ' Column width in pixels + Dim width As Integer = worksheet.GetColumnWidthInPixels(range.Column) + ' Row height in pixels + Dim height As Integer = worksheet.GetRowHeightInPixels(range.Row) + + workbook.SaveAs("GridLineColor.xlsx") + End Using +{% endhighlight %} +{% endtabs %} + +## See Also + +* [How to format text within a cell?](https://help.syncfusion.com/document-processing/excel/excel-library/net/faqs/how-to-format-text-within-a-cell) +* [How to unfreeze the rows and columns in XlsIO?](https://help.syncfusion.com/document-processing/excel/excel-library/net/faqs/how-to-unfreeze-the-rows-and-columns-in-xlsio) +* [What is the maximum range of Rows and Columns?](https://help.syncfusion.com/document-processing/excel/excel-library/net/faqs/what-is-the-maximum-range-of-rows-and-columns) +* [How to find values with a matching case for specific column in Excel?](https://help.syncfusion.com/document-processing/excel/excel-library/net/faqs/how-to-find-values-with-a-matching-case-for-specific-column-in-excel) +* [How to protect certain cells in a worksheet?](https://help.syncfusion.com/document-processing/excel/excel-library/net/faqs/how-to-protect-certain-cells-in-a-worksheet) +* [How to search a value in only specific columns of an Excel worksheet?](https://help.syncfusion.com/document-processing/excel/excel-library/net/faqs/how-to-search-a-value-in-only-specific-columns-of-an-excel-worksheet) From 4d7f84c0fd6a7a4da5eeeeeedf4e2afe0c5c8b51 Mon Sep 17 00:00:00 2001 From: KarthikaSF4773 Date: Tue, 21 Oct 2025 18:14:40 +0530 Subject: [PATCH 2/5] 983387-MultipleMarker --- ...support-multiple-markers-in-a-single-Excel-cell.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Document-Processing/Excel/Excel-Library/NET/faqs/does-xlsio-support-multiple-markers-in-a-single-Excel-cell.md diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/does-xlsio-support-multiple-markers-in-a-single-Excel-cell.md b/Document-Processing/Excel/Excel-Library/NET/faqs/does-xlsio-support-multiple-markers-in-a-single-Excel-cell.md new file mode 100644 index 000000000..75583ab19 --- /dev/null +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/does-xlsio-support-multiple-markers-in-a-single-Excel-cell.md @@ -0,0 +1,11 @@ +--- +title: XlsIO support for multiple markers in a single cell | Syncfusion +description: Learn whether Syncfusion XlsIO supports multiple markers in a single Excel cell using the Syncfusion .NET Excel library (XlsIO). +platform: document-processing +control: XlsIO +documentation: UG +--- + +# Does XlsIO support multiple markers in a single Excel cell? + +No, XlsIO does not support multiple markers in a single Excel cell. Only one marker is allowed per cell when using template markers. \ No newline at end of file From 65b7b56a3bc7e2cc00d171c63a051898bfc7e289 Mon Sep 17 00:00:00 2001 From: Ramya Sivakumar Date: Fri, 24 Oct 2025 18:36:48 +0530 Subject: [PATCH 3/5] 988874-ModifyStreams --- .../Working-with-Cell-or-Range-Formatting.md | 82 ++++--------------- 1 file changed, 14 insertions(+), 68 deletions(-) diff --git a/Document-Processing/Excel/Excel-Library/NET/Working-with-Cell-or-Range-Formatting.md b/Document-Processing/Excel/Excel-Library/NET/Working-with-Cell-or-Range-Formatting.md index 6dff372a8..89a094af2 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Working-with-Cell-or-Range-Formatting.md +++ b/Document-Processing/Excel/Excel-Library/NET/Working-with-Cell-or-Range-Formatting.md @@ -33,12 +33,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/CreateStyle.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/CreateStyle.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -110,12 +106,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/RowColumnStyle.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/RowColumnStyle.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -257,12 +249,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/GlobalStyle.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/GlobalStyle.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -687,12 +675,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/NumberFormat.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/NumberFormat.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -873,9 +857,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) string text = worksheet.Range["B4"].DisplayText; //Saving the workbook as stream - FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(stream); - stream.Dispose(); + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} @@ -970,12 +952,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/HideCellContent.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/HideCellContent.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -1189,12 +1167,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Alignment.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Alignment.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -1374,12 +1348,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/MergeandUnMerge.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/MergeandUnMerge.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -1445,12 +1415,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/WrapText.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/WrapText.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -1542,12 +1508,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/AutoFit.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/AutoFit.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -1643,12 +1605,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/FontSettings.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/FontSettings.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -1860,12 +1818,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/BorderSettings.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/BorderSettings.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -1996,12 +1950,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/HTMLString.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/HTMLString.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} @@ -2105,12 +2055,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/RichText.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/RichText.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); } {% endhighlight %} From cd443d5c04f30f64f75eac5abc22bc010dda2079 Mon Sep 17 00:00:00 2001 From: KarthikaSF4773 Date: Mon, 27 Oct 2025 12:45:13 +0530 Subject: [PATCH 4/5] 988804-ModifyStreams --- .../Conditional-Formatting/Color-Scales.md | 10 +--- .../NET/Conditional-Formatting/Data-Bars.md | 10 +--- .../Conditional-Formatting/Highlight-Cells.md | 6 +-- .../NET/Conditional-Formatting/Icon-Sets.md | 10 +--- .../NET/Conditional-Formatting/Top-Bottom.md | 40 ++++------------ .../Working-with-Conditional-Formatting.md | 48 ++++--------------- 6 files changed, 25 insertions(+), 99 deletions(-) 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 %} From 822e582ef072bb7a9bf9e7f01e3d43a0ee0ac9c6 Mon Sep 17 00:00:00 2001 From: KarthikaSF4773 Date: Mon, 27 Oct 2025 14:53:53 +0530 Subject: [PATCH 5/5] 988804-ModifyStreams --- .../Excel/Excel-Library/NET/Working-with-Data-Validation.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Document-Processing/Excel/Excel-Library/NET/Working-with-Data-Validation.md b/Document-Processing/Excel/Excel-Library/NET/Working-with-Data-Validation.md index 053e8a4f0..e6232f953 100644 --- a/Document-Processing/Excel/Excel-Library/NET/Working-with-Data-Validation.md +++ b/Document-Processing/Excel/Excel-Library/NET/Working-with-Data-Validation.md @@ -337,9 +337,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) validation.PromptBoxText = "Custom DataValidation"; validation.ShowPromptBox = true; - FileStream file = new FileStream("DataValidation.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(file); - file.Dispose(); + workbook.SaveAs("DataValidation.xlsx"); } {% endhighlight %}