diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-retain-cell-values-after-removing-formulas-in-Excel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-retain-cell-values-after-removing-formulas-in-Excel.md index 98d3dae43..1b0e600f2 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-retain-cell-values-after-removing-formulas-in-Excel.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/How-to-retain-cell-values-after-removing-formulas-in-Excel.md @@ -18,8 +18,7 @@ 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); + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); IWorksheet worksheet = workbook.Worksheets[0]; //Enable sheet calculation @@ -41,10 +40,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) } } - //Saving the workbook as stream - FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(outputStream); - outputStream.Dispose(); + //Saving the workbook + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/does-xlsio-support-the-multiline-header-footer-support.md b/Document-Processing/Excel/Excel-Library/NET/faqs/does-xlsio-support-the-multiline-header-footer-support.md index 100fe20fd..90ce14455 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/does-xlsio-support-the-multiline-header-footer-support.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/does-xlsio-support-the-multiline-header-footer-support.md @@ -34,8 +34,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) pageSetup.RightFooter = "Right Footer Line 1\nRight Footer Line 2"; //Save the excel file - FileStream outputStream = new FileStream("Output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite); - workbook.SaveAs(outputStream); + workbook.SaveAs("Output.xlsx"); workbook.Close(); excelEngine.Dispose(); } diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-does-excel-file-with-uninstalled-fonts-is-converted-to-pdf-image.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-does-excel-file-with-uninstalled-fonts-is-converted-to-pdf-image.md index eff65fcd2..f22b5ba74 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-does-excel-file-with-uninstalled-fonts-is-converted-to-pdf-image.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-does-excel-file-with-uninstalled-fonts-is-converted-to-pdf-image.md @@ -19,8 +19,7 @@ The following code snippet shows how to use font substitution in Excel to PDF co using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; - FileStream fileStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(fileStream); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); //Initializes the SubstituteFont event to perform font substitution during Excel to PDF conversion application.SubstituteFont += new SubstituteFontEventHandler(SubstituteFont); @@ -28,8 +27,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) XlsIORenderer renderer = new XlsIORenderer(); PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); - FileStream stream = new FileStream("Output.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite); - pdfDocument.Save(stream); + pdfDocument.Save("Output.pdf"); } private static void SubstituteFont(object sender, SubstituteFontEventArgs args) diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-access-a-table-in-Excel-document-using-the-table-name.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-access-a-table-in-Excel-document-using-the-table-name.md index 5a9121427..08eb31b6f 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-access-a-table-in-Excel-document-using-the-table-name.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-access-a-table-in-Excel-document-using-the-table-name.md @@ -16,8 +16,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("D:../../../Data/InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); IWorksheet worksheet = workbook.Worksheets[0]; //Initialize the table @@ -38,9 +37,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) } } - //Saving the workbook as stream - FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(outputStream); + //Saving the workbook + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-add-Barcode-in-Excel-document.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-add-Barcode-in-Excel-document.md index bff77c51a..158bbd941 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-add-Barcode-in-Excel-document.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-add-Barcode-in-Excel-document.md @@ -25,8 +25,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) worksheet.Pictures.AddPicture(15, 10, barcode2); // Save to file system - FileStream stream = new FileStream("Output.xlsx",FileMode.OpenOrCreate, FileAccess.ReadWrite); - workbook.SaveAs(stream); + workbook.SaveAs("Output.xlsx"); workbook.Close(); excelEngine.Dispose(); } diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-add-and-remove-page-breaks-in-Excel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-add-and-remove-page-breaks-in-Excel.md index 07254d5e7..43a5656fb 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-add-and-remove-page-breaks-in-Excel.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-add-and-remove-page-breaks-in-Excel.md @@ -38,12 +38,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Setting sheet view to see the page breaks worksheet.View = SheetView.PageBreakPreview; - //Saving the workbook as stream - FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); + //Saving the workbook + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-add-oval-shape-to-Excel-chart.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-add-oval-shape-to-Excel-chart.md index 822e446b1..70e58c8b1 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-add-oval-shape-to-Excel-chart.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-add-oval-shape-to-Excel-chart.md @@ -1,6 +1,6 @@ --- title: How to add Oval shape to Excel chart using XlsIO | Syncfusion -description: Code example to add Oval shape to Excel chart using Syncfusion .NET Excel library (XlsIO). +description: This page explains how to add Oval shape to Excel chart in C# (cross-platform and Windows-specific) and VB.NET using Syncfusion .NET Excel library (XlsIO). platform: document-processing control: XlsIO documentation: UG @@ -35,12 +35,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/faqs/how-to-apply-TimePeriod-conditional-formatting-in-Excel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-TimePeriod-conditional-formatting-in-Excel.md index 84d12a1f9..ce32da596 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-TimePeriod-conditional-formatting-in-Excel.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-TimePeriod-conditional-formatting-in-Excel.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/Input.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Input.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; //Apply conditional format for specific time period @@ -34,12 +33,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) conditionalFormat.BackColor = ExcelKnownColors.Sky_blue; //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-custom-filtering-to-string-data-types-using-XlsIO.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-custom-filtering-to-string-data-types-using-XlsIO.md index b29c3092b..427c13e6f 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-custom-filtering-to-string-data-types-using-XlsIO.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-custom-filtering-to-string-data-types-using-XlsIO.md @@ -16,8 +16,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Input.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; //Creating an AutoFilter @@ -30,12 +29,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) firstCondition.String = "1000.00"; //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + workbook.SaveAs(Path.GetFullPath(@"Output/Output.xlsx")); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-formatting-to-pivottable-in-Excel-protected-view.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-formatting-to-pivottable-in-Excel-protected-view.md index 336b7de27..5e1faa19c 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-formatting-to-pivottable-in-Excel-protected-view.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-formatting-to-pivottable-in-Excel-protected-view.md @@ -16,8 +16,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream fileStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(fileStream); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); IWorksheet worksheet = workbook.Worksheets[0]; IWorksheet pivotSheet = workbook.Worksheets[1]; @@ -40,10 +39,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) pivotTable.BuiltInStyle = PivotBuiltInStyles.PivotStyleDark15; pivotTable.Layout(); - //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("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-rotation-and-transparency-to-background-image.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-rotation-and-transparency-to-background-image.md index 390cdca26..4c409c017 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-rotation-and-transparency-to-background-image.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-apply-rotation-and-transparency-to-background-image.md @@ -17,8 +17,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IApplication application = excelEngine.Excel; //Load an existing Excel file into IWorkbook - FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); IWorksheet worksheet = workbook.Worksheets[0]; System.Drawing.Image image = System.Drawing.Image.FromFile("image.png"); @@ -37,13 +36,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs("Output.xlsx"); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %} {% endtabs %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-exception-when-adding-worksheets-with-same-name.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-exception-when-adding-worksheets-with-same-name.md index 9b411ce7a..4b35085f8 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-exception-when-adding-worksheets-with-same-name.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-exception-when-adding-worksheets-with-same-name.md @@ -27,10 +27,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet sheet_1 = workbook.Worksheets.Create("Sheet"); IWorksheet sheet_2 = workbook.Worksheets.Create("Sheet"); - //Saving the workbook as stream - FileStream file = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(file); - file.Dispose(); + //Saving the workbook + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-header-row-while-sorting-Excel-data.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-header-row-while-sorting-Excel-data.md index d08f31105..ed34ad13e 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-header-row-while-sorting-Excel-data.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-header-row-while-sorting-Excel-data.md @@ -51,9 +51,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) sorter.Sort(); worksheet.UsedRange.AutofitColumns(); - FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(stream); - stream.Dispose(); + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-processing-unnecessary-worksheets-when-opening-an-Excel-document-using-C#.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-processing-unnecessary-worksheets-when-opening-an-Excel-document-using-C#.md deleted file mode 100644 index 2c09e682d..000000000 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-processing-unnecessary-worksheets-when-opening-an-Excel-document-using-C#.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -title: How to avoid processing unnecessary worksheets when opening an Excel document using C# | Syncfusion -description: Code example to avoid processing unnecessary worksheets when opening an Excel document using Syncfusion .NET Excel library (XlsIO). -platform: document-processing -control: XlsIO -documentation: UG ---- -# How to avoid processing unnecessary worksheets when opening an Excel document using C#? -XlsIO provides support to avoid processing unnecessary worksheets when opening an Excel. The following code snippet illustrates this. -{% tabs %} -{% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/FAQ/Worksheet/.NET/Parse%20Worksheets%20On%20Demand/Parse%20Worksheets%20On%20Demand/Program.cs,180" %} -using (ExcelEngine excelEngine = new ExcelEngine()) -{ - IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("Input.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream,ExcelOpenType.Automatic, ExcelParseOptions.ParseWorksheetsOnDemand); - - // Access the first worksheet (triggers parsing) - IWorksheet worksheet = workbook.Worksheets[0]; - - // Process your data - string value = worksheet.Range["A1"].Text; - - // Save to file system - FileStream stream = new FileStream("Output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite); - workbook.SaveAs(stream); - workbook.Close(); - excelEngine.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("Input.xlsx",ExcelOpenType.Automatic,ExcelParseOptions.ParseWorksheetsOnDemand); - - // Access the first worksheet (triggers parsing) - IWorksheet worksheet = workbook.Worksheets[0]; - - // Process your data - string value = worksheet.Range["A1"].Text; - workbook.SaveAs("Output.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.Xlsx - Dim workbook As IWorkbook = application.Workbooks.Open("Input.xlsx", ExcelParseOptions.ParseWorksheetsOnDemand) - - ' Access the first worksheet (triggers parsing) - Dim worksheet As IWorksheet = workbook.Worksheets(0) - - ' Process your data... - Dim value As String = worksheet.Range("A1").Text - - workbook.SaveAs("Output.xlsx") - End Using -{% endhighlight %} -{% endtabs %} - -A complete working example to avoid processing unnecessary worksheets when opening an Excel document using C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/FAQ/Worksheet/.NET/Parse%20Worksheets%20On%20Demand). diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-processing-unnecessary-worksheets-when-opening-an-Excel-document.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-processing-unnecessary-worksheets-when-opening-an-Excel-document.md index 8e53defaa..efc82eaa6 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-processing-unnecessary-worksheets-when-opening-an-Excel-document.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-avoid-processing-unnecessary-worksheets-when-opening-an-Excel-document.md @@ -5,7 +5,7 @@ platform: document-processing control: XlsIO documentation: UG --- -# How to avoid processing unnecessary worksheets when opening an Excel document using C#? +# How to avoid processing unnecessary worksheets using C#? XlsIO provides support to avoid processing unnecessary worksheets when opening an Excel. The following code snippet illustrates this. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/XlsIO-Examples/master/FAQ/Worksheet/.NET/Parse%20Worksheets%20On%20Demand/Parse%20Worksheets%20On%20Demand/Program.cs,180" %} @@ -13,8 +13,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("Input.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream,ExcelOpenType.Automatic, ExcelParseOptions.ParseWorksheetsOnDemand); + IWorkbook workbook = application.Workbooks.Open("Input.xlsx",ExcelOpenType.Automatic, ExcelParseOptions.ParseWorksheetsOnDemand); // Access the first worksheet (triggers parsing) IWorksheet worksheet = workbook.Worksheets[0]; @@ -23,8 +22,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) string value = worksheet.Range["A1"].Text; // Save to file system - FileStream stream = new FileStream("Output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite); - workbook.SaveAs(stream); + workbook.SaveAs("Output.xlsx"); workbook.Close(); excelEngine.Dispose(); } diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-change-data-point-label-color-of-a-waterfall-chart.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-change-data-point-label-color-of-a-waterfall-chart.md index 10c88b294..8b51a47a4 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-change-data-point-label-color-of-a-waterfall-chart.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-change-data-point-label-color-of-a-waterfall-chart.md @@ -16,8 +16,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2016; - FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream,ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx",ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Accessing first chart in the sheet @@ -27,10 +26,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) chart.Series[0].DataPoints[0].DataLabels.IsValue = true; chart.Series[0].DataPoints[0].DataLabels.RGBColor = Color.Green; - //Saving the workbook as stream - FileStream stream = new FileStream("Waterfall.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(stream); - stream.Dispose(); + //Saving the workbook + workbook.SaveAs("Waterfall.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-change-the-shape-text-font.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-change-the-shape-text-font.md index 20fc2fd75..45e205102 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-change-the-shape-text-font.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-change-the-shape-text-font.md @@ -16,8 +16,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); IWorksheet worksheet = workbook.Worksheets[0]; IFont font = workbook.CreateFont(); @@ -27,10 +26,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IShape shape = worksheet.Shapes[0]; shape.TextFrame.TextRange.RichText.SetFont(1, 3, font); - //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("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-whether-an-excel-document-contains-macro.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-whether-an-excel-document-contains-macro.md index 1519f4f72..cfaf070c9 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-whether-an-excel-document-contains-macro.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-whether-an-excel-document-contains-macro.md @@ -18,18 +18,14 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IApplication application = excelEngine.Excel; //Opening form module existing workbook - FileStream input = new FileStream("Test.xls", FileMode.Open, FileAccess.ReadWrite); - IWorkbook workbook = application.Workbooks.Open(input); + IWorkbook workbook = application.Workbooks.Open("Test.xls"); IWorksheet sheet = workbook.Worksheets[0]; //Check macro exist bool IsMacroEnabled = workbook.HasMacros; // Save the workbook - FileStream output = new FileStream("Output.xls", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(output); - input.Close(); - output.Close(); + workbook.SaveAs("Output.xls"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-whether-the-loaded-file-is-an-excel-file.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-whether-the-loaded-file-is-an-excel-file.md index 3c9879450..67fe7fded 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-whether-the-loaded-file-is-an-excel-file.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-check-whether-the-loaded-file-is-an-excel-file.md @@ -25,10 +25,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Open the workbook IWorkbook workbook = application.Workbooks.Open(inputStream); - //Saving the workbook as stream - FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - outputStream.Dispose(); + //Saving the workbook + workbook.SaveAs("Output.xlsx"); } else { diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-hidden-worksheets-alone-to-image.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-hidden-worksheets-alone-to-image.md index d499351f4..352b71c25 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-hidden-worksheets-alone-to-image.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-hidden-worksheets-alone-to-image.md @@ -21,8 +21,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) application.XlsIORenderer = new XlsIORenderer(); //Opening workbook with hidden worksheets - FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); //Converting only hidden worksheets to image foreach (IWorksheet worksheet in workbook.Worksheets) diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-image-from-url-in-excel-to-pdf.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-image-from-url-in-excel-to-pdf.md index bed4ff2aa..e79771512 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-image-from-url-in-excel-to-pdf.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-image-from-url-in-excel-to-pdf.md @@ -32,9 +32,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Convert Excel document into PDF document PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); - FileStream stream = new FileStream("ExcelToPDF.pdf", FileMode.Create, FileAccess.ReadWrite); - pdfDocument.Save(stream); - stream.Dispose(); + pdfDocument.Save("ExcelToPDF.pdf"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-json-document-to-csv-format-document.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-json-document-to-csv-format-document.md index c31c32918..a69a5bc75 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-json-document-to-csv-format-document.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-json-document-to-csv-format-document.md @@ -31,11 +31,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) sheet.ImportDataTable(dataTable, true, 1, 1); //Saving the workbook as CSV - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Sample.csv"), FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(outputStream, ","); - - //Dispose streams - outputStream.Dispose(); + workbook.SaveAs(Path.GetFullPath("Output/Sample.csv"), ","); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-the-required-range-in-excel-to-pdf.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-the-required-range-in-excel-to-pdf.md index cf72e6147..11d76efa7 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-the-required-range-in-excel-to-pdf.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-the-required-range-in-excel-to-pdf.md @@ -16,8 +16,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream excelStream = new FileStream("ExceltoPDF.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(excelStream); + IWorkbook workbook = application.Workbooks.Open("ExceltoPDF.xlsx"); IWorksheet sheet = workbook.Worksheets[0]; XlsIORendererSettings settings = new XlsIORendererSettings(); @@ -35,10 +34,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) XlsIORenderer renderer = new XlsIORenderer(); //Convert Excel document into PDF document PdfDocument pdfDocument = renderer.ConvertToPDF(tempWorksheet, settings); - Stream stream = new FileStream("ExcelToPDF.pdf", FileMode.Create, FileAccess.ReadWrite); - pdfDocument.Save(stream); - excelStream.Dispose(); - stream.Dispose(); + pdfDocument.Save("ExcelToPDF.pdf"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-xls-document-to-xlsx-format-document.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-xls-document-to-xlsx-format-document.md index 341b3f188..c0146c6b0 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-xls-document-to-xlsx-format-document.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-convert-xls-document-to-xlsx-format-document.md @@ -18,16 +18,13 @@ using (ExcelEngine excelEngine = new ExcelEngine()) application.DefaultVersion = ExcelVersion.Xlsx; //Loads an xls file - FileStream fileStream = new FileStream("InputTemplate.xls", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(fileStream); + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xls"); //Set the workbook version to xlsx workbook.Version = ExcelVersion.Xlsx; - //Saving the workbook as stream in xlsx format - FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(stream); - stream.Dispose(); + //Saving the workbook in xlsx format + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-delete-blank-rows-and-columns-in-a-worksheet.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-delete-blank-rows-and-columns-in-a-worksheet.md index a1d12ac19..f28d58296 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-delete-blank-rows-and-columns-in-a-worksheet.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-delete-blank-rows-and-columns-in-a-worksheet.md @@ -18,8 +18,7 @@ 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); + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); IWorksheet worksheet = workbook.Worksheets[0]; //Get the used range of the worksheet @@ -43,13 +42,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) } } - //Saving the workbook as stream - FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(outputStream); - - //Dispose streams - inputStream.Dispose(); - outputStream.Dispose(); + //Saving the workbook + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-delete-hyperlinks-from-worksheet-without-affecting-the-cell-styles.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-delete-hyperlinks-from-worksheet-without-affecting-the-cell-styles.md index 9c8b4256e..c0ac1ca3e 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-delete-hyperlinks-from-worksheet-without-affecting-the-cell-styles.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-delete-hyperlinks-from-worksheet-without-affecting-the-cell-styles.md @@ -6,7 +6,7 @@ control: XlsIO documentation: UG --- -# How to delete hyperlinks from a worksheet without affecting the cell styles using C#? +# How to delete worksheet hyperlinks without affecting cell styles? You can remove hyperlinks from an Excel worksheet without altering the cell formatting using [HyperLinks]( https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_HyperLinks) property of the [IWorksheet]( https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html) interface. Below are the code examples in C# (cross-platform and Windows-specific) and VB.NET to demonstrate how to do this. @@ -16,14 +16,13 @@ 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 worksheet = workbook.Worksheets[0]; // Remove first hyperlink without affecting cell styles HyperLinksCollection hyperlink = worksheet.HyperLinks as HyperLinksCollection; hyperlink.Remove(hyperlink[0] as HyperLinkImpl); - FileStream outputStream = new FileStream("Output/Output.xlsx", FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + FileStream outputStream = new FileStream(, FileMode.Create, FileAccess.Write); + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); workbook.Close(); excelEngine.Dispose(); } diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-detect-merged-cells-in-Excel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-detect-merged-cells-in-Excel.md index f9406f776..6b93dedb2 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-detect-merged-cells-in-Excel.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-detect-merged-cells-in-Excel.md @@ -16,8 +16,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream fileStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(fileStream); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); IWorksheet worksheet = workbook.Worksheets[0]; //Create a new worksheet @@ -32,10 +31,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Autofit the used range mergedCells.UsedRange.AutofitColumns(); - //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("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-edit-external-workbook-reference-link.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-edit-external-workbook-reference-link.md index 1a0e7c603..604b7ac59 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-edit-external-workbook-reference-link.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-edit-external-workbook-reference-link.md @@ -17,14 +17,12 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); string filepath = (workbook as WorkbookImpl).ExternWorkbooks[0].URL; (workbook as WorkbookImpl).ExternWorkbooks[0].URL = DataPathBase + "Template.xlsx"; - FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-and-highlight-data-in-Excel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-and-highlight-data-in-Excel.md index 66090311b..c4fa32f21 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-and-highlight-data-in-Excel.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-and-highlight-data-in-Excel.md @@ -25,8 +25,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); IWorksheet worksheet = workbook.Worksheets[0]; //Finds a value 1500 in a sheet and highlights the cell which contains the value @@ -35,10 +34,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) range.CellStyle.Color = ExcelKnownColors.Green; } - //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("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-and-replace-text-in-hyperlinks.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-and-replace-text-in-hyperlinks.md index db1266481..8c6c667c1 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-and-replace-text-in-hyperlinks.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-and-replace-text-in-hyperlinks.md @@ -18,8 +18,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) application.DefaultVersion = ExcelVersion.Xlsx; //Loads an existing file. - FileStream inputstream = new FileStream("InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputstream); + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); IWorksheet sheet = workbook.Worksheets[0]; //Find and Replace text in hyperlinks @@ -34,9 +33,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) } // Saving the workbook - FileStream outputstream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(outputstream); - outputstream.Dispose(); + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-duplicate-values-in-the-Excel-document-using-formulas.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-duplicate-values-in-the-Excel-document-using-formulas.md index c03d58031..075f69991 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-duplicate-values-in-the-Excel-document-using-formulas.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-duplicate-values-in-the-Excel-document-using-formulas.md @@ -18,8 +18,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) application.DefaultVersion = ExcelVersion.Xlsx; //Loads an existing file. - FileStream inputStream = new FileStream("InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); IWorksheet worksheet = workbook.Worksheets[0]; //Find duplicate values in the column @@ -28,9 +27,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) worksheet.Range["D" + i].Formula = $"=IF(MATCH(C{i},C$2:C{i},0)=ROW(C{i})-1,1,0)"; } - //Saving the workbook as stream - FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + //Saving the workbook + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-values-with-a-matching-case-for-specific-column-in-Excel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-values-with-a-matching-case-for-specific-column-in-Excel.md index 3568e0708..30726b4d2 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-values-with-a-matching-case-for-specific-column-in-Excel.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-find-values-with-a-matching-case-for-specific-column-in-Excel.md @@ -15,8 +15,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream fileStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(fileStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); IWorksheet worksheet = workbook.Worksheets[0]; IRange[] range1 = (worksheet as WorksheetImpl).Find(worksheet.Range["C1"].EntireColumn, "90", ExcelFindType.Number, ExcelFindOptions.MatchCase, false); diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-RGB-values-of-a-cells-background-color.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-RGB-values-of-a-cells-background-color.md index ee955af50..53dbcb1d7 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-RGB-values-of-a-cells-background-color.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-RGB-values-of-a-cells-background-color.md @@ -32,11 +32,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) Console.WriteLine($"Red: {red}, Green: {green}, Blue: {blue}"); //Save the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - - //Dispose stream - outputStream.Dispose(); + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-the-frozen-rows-and-columns-in-an-excel-document.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-the-frozen-rows-and-columns-in-an-excel-document.md index 383c12ae2..b55541067 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-the-frozen-rows-and-columns-in-an-excel-document.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-the-frozen-rows-and-columns-in-an-excel-document.md @@ -16,8 +16,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 worksheet = workbook.Worksheets[0]; //Get the pane record @@ -34,9 +33,6 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Get the no of frozen columns int frozencolumns = paneRecord.VerticalSplit; - - //Dispose streams - inputStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-the-list-of-worksheet-names-in-an-Excel-workbook.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-the-list-of-worksheet-names-in-an-Excel-workbook.md index e3df070e2..b0e56b885 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-the-list-of-worksheet-names-in-an-Excel-workbook.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-get-the-list-of-worksheet-names-in-an-Excel-workbook.md @@ -21,8 +21,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("Data/Input.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Input.xlsx")); //Get the worksheets collection WorksheetsCollection worksheets = workbook.Worksheets as WorksheetsCollection; @@ -32,9 +31,6 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { Console.WriteLine(worksheet.Name); } - - //Dispose streams - inputStream.Dispose(); } {% endhighlight %} @@ -87,8 +83,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("Data/Input.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Input.xlsx")); //Get the worksheets collection WorksheetsCollection worksheets = workbook.Worksheets as WorksheetsCollection; @@ -99,9 +94,6 @@ using (ExcelEngine excelEngine = new ExcelEngine()) if (worksheet.Visibility == WorksheetVisibility.Visible) Console.WriteLine(worksheet.Name); } - - //Dispose streams - inputStream.Dispose(); } {% endhighlight %} @@ -158,8 +150,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream inputStream = new FileStream("Data/Input.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Input.xlsx")); //Get the worksheets collection WorksheetsCollection worksheets = workbook.Worksheets as WorksheetsCollection; @@ -170,9 +161,6 @@ using (ExcelEngine excelEngine = new ExcelEngine()) if (worksheet.Visibility == WorksheetVisibility.Hidden) Console.WriteLine(worksheet.Name); } - - //Dispose streams - inputStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-hide-columns-using-column-name.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-hide-columns-using-column-name.md index 46b3b3a12..37d903326 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-hide-columns-using-column-name.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-hide-columns-using-column-name.md @@ -18,8 +18,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) application.DefaultVersion = ExcelVersion.Xlsx; //Loads an existing file - FileStream inputStream = new FileStream("InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); IWorksheet worksheet = workbook.Worksheets[0]; List columnsToHide = new List { "column1", "column2", "column3" }; @@ -36,10 +35,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) } } - //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("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-open-an-excel-document-that-is-already-open-in-msexcel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-open-an-excel-document-that-is-already-open-in-msexcel.md index 478cde104..c2d62f627 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-open-an-excel-document-that-is-already-open-in-msexcel.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-open-an-excel-document-that-is-already-open-in-msexcel.md @@ -18,10 +18,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2016; - FileStream inputStream = new FileStream("Template.xlsx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - IWorkbook workbook = application.Workbooks.Open(inputStream); - FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(outputStream); + IWorkbook workbook = application.Workbooks.Open("Template.xlsx"); + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-open-an-excel-file-with-encoding-in-net-core.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-open-an-excel-file-with-encoding-in-net-core.md index 10c805db6..fdd699f01 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-open-an-excel-file-with-encoding-in-net-core.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-open-an-excel-file-with-encoding-in-net-core.md @@ -16,13 +16,11 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; - FileStream stream = new FileStream("Sample.csv", FileMode.Open, FileAccess.Read); -  System.Text.UnicodeEncoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); -  IWorkbook workbook = application.Workbooks.Open(stream, System.Text.UnicodeEncoding.GetEncoding("big5")); + System.Text.UnicodeEncoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); + IWorkbook workbook = application.Workbooks.Open("Sample.csv", System.Text.UnicodeEncoding.GetEncoding("big5")); -  FileStream outputStream = new FileStream("Output.csv", FileMode.Create, FileAccess.Write); -  workbook.SaveAs(outputStream, ","); + workbook.SaveAs("Output.csv", ","); } {% endhighlight %} -{% endtabs %} +{% endtabs %} \ No newline at end of file diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-override-an-Excel-document.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-override-an-Excel-document.md index 972e2bded..37e2a567c 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-override-an-Excel-document.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-override-an-Excel-document.md @@ -20,24 +20,16 @@ using (ExcelEngine excelEngine = new ExcelEngine()) application.DefaultVersion = ExcelVersion.Xlsx; //Open an existing Excel file as stream - FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Sample.xlsx"), FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream); + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Sample.xlsx")); IWorksheet worksheet = workbook.Worksheets[0]; //Modify the data worksheet.Range["A1"].Text = "Hello World"; - //Dispose input stream - inputStream.Dispose(); - #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Sample.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Sample.xlsx")); #endregion - - //Dispose output stream - outputStream.Dispose(); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-read-filtered-rows-in-excel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-read-filtered-rows-in-excel.md index a67409b5f..974641d1a 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-read-filtered-rows-in-excel.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-read-filtered-rows-in-excel.md @@ -16,8 +16,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream fileStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(fileStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); IWorksheet worksheet = workbook.Worksheets[0]; IRange usedRange = worksheet.UsedRange; diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-autofilter-in-an-Excel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-autofilter-in-an-Excel.md index 78e7edf16..2b93c6027 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-autofilter-in-an-Excel.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-autofilter-in-an-Excel.md @@ -18,17 +18,15 @@ 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); + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); IWorksheet worksheet = workbook.Worksheets[0]; //Remove autofilter from worksheet IAutoFilters filter = worksheet.AutoFilters; filter.FilterRange = null; - //Saving the workbook as stream - FileStream OutputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(OutputStream); + //Saving the workbook + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-data-validation-from-the-specified-range.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-data-validation-from-the-specified-range.md index 27f3a40c6..d8d0e8524 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-data-validation-from-the-specified-range.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-remove-data-validation-from-the-specified-range.md @@ -18,16 +18,14 @@ 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); + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); IWorksheet worksheet = workbook.Worksheets[0]; //Removes data validation from the specified range worksheet.Range["A1:C5"].Clear(ExcelClearOptions.ClearDataValidations); - //Saving the workbook as stream - FileStream OutputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(OutputStream); + //Saving the workbook + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-excel-cannot-open-the-file-because-the-file-format-for-the-file-extension-is-not-valid.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-excel-cannot-open-the-file-because-the-file-format-for-the-file-extension-is-not-valid.md index 37570bef6..9a16f7b31 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-excel-cannot-open-the-file-because-the-file-format-for-the-file-extension-is-not-valid.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-excel-cannot-open-the-file-because-the-file-format-for-the-file-extension-is-not-valid.md @@ -22,8 +22,7 @@ application.DefaultVersion = ExcelVersion.Excel2013; //Do some manipulation //Workbook is saved in Excel2013 format -FileStream stream = new FileStream("Sample.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite); -workbook.SaveAs(stream); +workbook.SaveAs("Sample.xlsx"); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} @@ -66,12 +65,10 @@ These are represented in the below code snippet. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} workbook.Version = ExcelVersion.Excel97to2003; -FileStream stream = new FileStream("Sample.xls", FileMode.OpenOrCreate, FileAccess.ReadWrite); -workbook.SaveAs(stream); +workbook.SaveAs("Sample.xls"); workbook.Version = ExcelVersion.Excel2013; -FileStream stream1 = new FileStream("Sample.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite); -workbook.SaveAs(stream1); +workbook.SaveAs("Sample.xlsx"); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md index a68fca7d4..ea27b54ae 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-performance-issue-when-deleting-a-large-number-of-rows.md @@ -20,8 +20,7 @@ using(ExcelEngine excelEngine = new ExcelEngine()) application.DefaultVersion = ExcelVersion.Xlsx; //Loads an existing file - FileStream fileStream = new FileStream("InputTemplate.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(fileStream); + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx"); IWorksheet worksheet = workbook.Worksheets[0]; IWorksheet newWorksheet = workbook.Worksheets[1]; @@ -44,10 +43,8 @@ using(ExcelEngine excelEngine = new ExcelEngine()) //Remove the worksheet workbook.Worksheets[0].Remove(); - //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("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-the-file-does-not-contain-workbook-stream-error.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-the-file-does-not-contain-workbook-stream-error.md index 0a9855a48..699b5cb5f 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-the-file-does-not-contain-workbook-stream-error.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-resolve-the-file-does-not-contain-workbook-stream-error.md @@ -16,8 +16,7 @@ ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; //To check whether the file is supported -FileStream stream = new FileStream("Sample.xls", FileMode.OpenOrCreate, FileAccess.ReadWrite); -var isSupported = application.IsSupported(stream); +var isSupported = application.IsSupported("Sample.xls"); excelEngine.Dispose(); {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-save-the-edited-chages-in-the-same-excel-document.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-save-the-edited-chages-in-the-same-excel-document.md index f4748cd19..d982fa5ee 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-save-the-edited-chages-in-the-same-excel-document.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-save-the-edited-chages-in-the-same-excel-document.md @@ -23,22 +23,14 @@ using (ExcelEngine excelEngine = new ExcelEngine()) string filepath = @"../../../Data/InputTemplate.xlsx"; //Load an Excel document - FileStream fileStream = new FileStream(filepath, FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(fileStream); + IWorkbook workbook = application.Workbooks.Open(filepath); IWorksheet worksheet = workbook.Worksheets[0]; //Set text in the cell worksheet["B1"].Text = "Text"; - //Close the input stream before writing - fileStream.Close(); - //Save the workbook to the same file - fileStream = new FileStream(filepath, FileMode.Create, FileAccess.Write); - workbook.SaveAs(fileStream); - - //Dispose the stream - fileStream.Dispose(); + workbook.SaveAs(filepath); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-search-a-value-in-only-specific-columns-of-an-Excel-worksheet.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-search-a-value-in-only-specific-columns-of-an-Excel-worksheet.md index 385de73be..1441730d5 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-search-a-value-in-only-specific-columns-of-an-Excel-worksheet.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-search-a-value-in-only-specific-columns-of-an-Excel-worksheet.md @@ -15,8 +15,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; - FileStream fileStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(fileStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); IWorksheet worksheet = workbook.Worksheets[0]; IRanges ranges = worksheet.CreateRangesCollection(); diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-and-format-time-values-in-Excel-using-TimeSpan.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-and-format-time-values-in-Excel-using-TimeSpan.md index c6b9f7964..b5bf3dd3f 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-and-format-time-values-in-Excel-using-TimeSpan.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-and-format-time-values-in-Excel-using-TimeSpan.md @@ -29,12 +29,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/faqs/how-to-set-column-width-for-a-pivot-table-range-in-an-Excel-Document.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-column-width-for-a-pivot-table-range-in-an-Excel-Document.md index 3436ec653..5c72fbb9a 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-column-width-for-a-pivot-table-range-in-an-Excel-Document.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-column-width-for-a-pivot-table-range-in-an-Excel-Document.md @@ -19,9 +19,7 @@ The following code examples demonstrate how to do this in C# (Cross-platform and 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]; IWorksheet worksheet1 = workbook.Worksheets[1]; @@ -46,13 +44,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/faqs/how-to-set-error-bars-in-chart.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-error-bars-in-chart.md index ee1ac6d65..3189c1143 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-error-bars-in-chart.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-error-bars-in-chart.md @@ -15,8 +15,7 @@ Charts can be enhanced by adding error bars which help to view the margin errors using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; - FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read); - IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Create a Chart @@ -31,8 +30,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Set error bar chart.Series[0].ErrorBar(true, ExcelErrorBarInclude.Plus, ExcelErrorBarType.Percentage, 50); - FileStream stream = new FileStream("ErrorBars.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite); - workbook.SaveAs(stream); + workbook.SaveAs("ErrorBars.xlsx"); workbook.Close(); excelEngine.Dispose(); } diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document.md index 709afb8ea..180598f7e 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-logarithmic-axis-for-chart-in-excel-document.md @@ -16,8 +16,7 @@ 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, ExcelOpenType.Automatic); + IWorkbook workbook = application.Workbooks.Open("InputTemplate.xlsx", ExcelOpenType.Automatic); IWorksheet sheet = workbook.Worksheets[0]; //Create a Chart @@ -37,12 +36,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) valueAxis.LogBase = 10; //Saving the workbook - FileStream outputStream = new FileStream("Chart.xlsx", FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); + workbook.SaveAs("Chart.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-rounded-corner-for-chart-in-excel-document.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-rounded-corner-for-chart-in-excel-document.md index 00fa2a305..10b254a87 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-rounded-corner-for-chart-in-excel-document.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-rounded-corner-for-chart-in-excel-document.md @@ -39,10 +39,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) serie.EnteredDirectlyValues = yValues; serie.EnteredDirectlyCategoryLabels = xValues; - //Saving the workbook as stream - FileStream stream = new FileStream("Chart.xlsx", FileMode.Create, FileAccess.ReadWrite); - workbook.SaveAs(stream); - stream.Dispose(); + //Saving the workbook + workbook.SaveAs("Chart.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-the-background-color-for-Excel-chart.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-the-background-color-for-Excel-chart.md index 216f830e2..ff67889cd 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-the-background-color-for-Excel-chart.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-the-background-color-for-Excel-chart.md @@ -19,8 +19,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]; //Get the first chart in the worksheet @@ -34,13 +33,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/faqs/how-to-set-the-default-font-and-font-size-in-an-Excel-workbook.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-the-default-font-and-font-size-in-an-Excel-workbook.md index 6929d6d7a..011e5505d 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-the-default-font-and-font-size-in-an-Excel-workbook.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-the-default-font-and-font-size-in-an-Excel-workbook.md @@ -28,9 +28,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) sheet.Range["A1"].Text = "This is default font and size"; //Save to file - FileStream outputStream = new FileStream("Output/Output.xlsx", FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - outputStream.Dispose(); + workbook.SaveAs(Path.GetFullPath("Output/Output.xlsx")); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-traffic-lights-icon-in-Excel-conditional-formatting.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-traffic-lights-icon-in-Excel-conditional-formatting.md index 0b631041b..7dc2ecc1d 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-traffic-lights-icon-in-Excel-conditional-formatting.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-set-traffic-lights-icon-in-Excel-conditional-formatting.md @@ -58,9 +58,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) iconSet.IconSet = ExcelIconSetType.ThreeTrafficLights1; //Saving the workbook - FileStream outputStream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); - outputStream.Dispose(); + workbook.SaveAs("Output.xlsx"); } {% endhighlight %} diff --git a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-show-the-leader-line-on-Excel-chart.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-show-the-leader-line-on-Excel-chart.md index 0ffac42d4..7f7c5bcc0 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-show-the-leader-line-on-Excel-chart.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-show-the-leader-line-on-Excel-chart.md @@ -47,12 +47,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/faqs/how-to-switch-chart-series-data-interpretation-from-horizontal-(rows)-to-vertical-(columns)-in-Excel.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-switch-chart-series-data-interpretation-from-horizontal-(rows)-to-vertical-(columns)-in-Excel.md index b57176545..2bb682973 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-switch-chart-series-data-interpretation-from-horizontal-(rows)-to-vertical-(columns)-in-Excel.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-switch-chart-series-data-interpretation-from-horizontal-(rows)-to-vertical-(columns)-in-Excel.md @@ -57,12 +57,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/faqs/how-to-use-and-or-operators-in-the-filters.md b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-use-and-or-operators-in-the-filters.md index f21c60f00..b78cf58df 100644 --- a/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-use-and-or-operators-in-the-filters.md +++ b/Document-Processing/Excel/Excel-Library/NET/faqs/how-to-use-and-or-operators-in-the-filters.md @@ -16,8 +16,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]; #region Filter @@ -41,13 +40,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) #region Save //Saving the workbook - FileStream outputStream = new FileStream(Path.GetFullPath("Output/Filter.xlsx"), FileMode.Create, FileAccess.Write); - workbook.SaveAs(outputStream); + workbook.SaveAs(Path.GetFullPath("Output/Filter.xlsx")); #endregion - - //Dispose streams - outputStream.Dispose(); - inputStream.Dispose(); } {% endhighlight %}