diff --git a/File-Formats/XlsIO/What-If-Analysis.md b/File-Formats/XlsIO/What-If-Analysis.md index 296786bf2..944de7085 100644 --- a/File-Formats/XlsIO/What-If-Analysis.md +++ b/File-Formats/XlsIO/What-If-Analysis.md @@ -8,12 +8,14 @@ documentation: UG # What-If Analysis +What-If Analysis is the process of changing the values in cells to see how those changes will affect the outcome of formulas on the worksheet. XlsIO supports the What-If Analysis of Scenarios type. + ## Scenario Manager Scenario Manager in Excel allows you to create and manage scenarios for different sets of input values to see how they impact the results of formulas in a worksheet. ### Create Scenario -The following code snippet explains how to create a scenario and add it to the worksheet. +The following code snippet explains how to create scenarios for different values in an Excel worksheet. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -27,12 +29,21 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IScenarios scenarios = worksheet.Scenarios; - //Add scenario with single range - IScenario scenario1 = scenarios.Add("Scenario1", worksheet.Range["B3"], 3000); - - //Add scenario with multiple range - List values = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario2 = scenarios.Add("Scenario2", worksheet.Range["B3:B9"], values); + //Initialize list objects with different values for scenarios + List currentChangePercentage_Values = new List { 0.23, 0.8, 1.1, 0.5, 0.35, 0.2}; + List increasedChangePercentage_Values = new List { 0.45, 0.56, 0.9, 0.5, 0.58, 0.43}; + List decreasedChangePercentage_Values = new List { 0.3, 0.2, 0.5, 0.3, 0.5, 0.23}; + List currentQuantity_Values = new List { 1500, 3000, 5000, 4000, 500, 4000 }; + List increasedQuantity_Values = new List { 1000, 5000, 4500, 3900, 10000, 8900 }; + List decreasedQuantity_Values = new List { 1000, 2000, 3000, 3000, 300, 4000 }; + + //Add scenarios in the worksheet with different values for the same cells + scenarios.Add("Current % of Change", worksheet.Range["F5:F10"], currentChangePercentage_Values); + scenarios.Add("Increased % of Change", worksheet.Range["F5:F10"], increasedChangePercentage_Values); + scenarios.Add("Decreased % of Change", worksheet.Range["F5:F10"], decreasedChangePercentage_Values); + scenarios.Add("Current Quantity", worksheet.Range["D5:D10"], currentQuantity_Values); + scenarios.Add("Increased Quantity", worksheet.Range["D5:D10"], increasedQuantity_Values); + scenarios.Add("Decreased Quantity", worksheet.Range["D5:D10"], decreasedQuantity_Values); //Saving the workbook as stream FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); @@ -51,12 +62,21 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IScenarios scenarios = worksheet.Scenarios; - //Add scenario with single range - IScenario scenario1 = scenarios.Add("Scenario1", worksheet.Range["B3"], 3000); - - //Add scenario with multiple range - List values = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario2 = scenarios.Add("Scenario2", worksheet.Range["B3:B9"], values); + //Initialize list objects with different values for scenarios + List currentChangePercentage_Values = new List { 0.23, 0.8, 1.1, 0.5, 0.35, 0.2}; + List increasedChangePercentage_Values = new List { 0.45, 0.56, 0.9, 0.5, 0.58, 0.43}; + List decreasedChangePercentage_Values = new List { 0.3, 0.2, 0.5, 0.3, 0.5, 0.23}; + List currentQuantity_Values = new List { 1500, 3000, 5000, 4000, 500, 4000 }; + List increasedQuantity_Values = new List { 1000, 5000, 4500, 3900, 10000, 8900 }; + List decreasedQuantity_Values = new List { 1000, 2000, 3000, 3000, 300, 4000 }; + + //Add scenarios in the worksheet with different values for the same cells + scenarios.Add("Current % of Change", worksheet.Range["F5:F10"], currentChangePercentage_Values); + scenarios.Add("Increased % of Change", worksheet.Range["F5:F10"], increasedChangePercentage_Values); + scenarios.Add("Decreased % of Change", worksheet.Range["F5:F10"], decreasedChangePercentage_Values); + scenarios.Add("Current Quantity", worksheet.Range["D5:D10"], currentQuantity_Values); + scenarios.Add("Increased Quantity", worksheet.Range["D5:D10"], increasedQuantity_Values); + scenarios.Add("Decreased Quantity", worksheet.Range["D5:D10"], decreasedQuantity_Values); //Saving the workbook workbook.SaveAs("Output.xlsx"); @@ -73,12 +93,20 @@ Using excelEngine As ExcelEngine = New ExcelEngine Dim scenarios As IScenarios = worksheet.Scenarios - 'Add scenario with single range - Dim scenario1 As IScenario = scenarios.Add("Scenario1", worksheet.Range("B3"), 3000) - - 'Add scenario with multiple range - Dim values1 As New List(Of Object) From {3000, 2000, 1000, 1600, 500, 1000, 30000} - Dim scenario2 As IScenario = scenarios.Add("Scenario2", worksheet.Range("B3:B9"), values1) + Dim currentChangePercentage_Values As List(Of Object) = New List(Of Object)() {0.23, 0.8, 1.1, 0.5, 0.35, 0.2} + Dim increasedChangePercentage_Values As List(Of Object) = New List(Of Object)() {0.45, 0.56, 0.9, 0.5, 0.58, 0.43} + Dim decreasedChangePercentage_Values As List(Of Object) = New List(Of Object)() {0.3, 0.2, 0.5, 0.3, 0.5, 0.23} + Dim currentQuantity_Values As List(Of Object) = New List(Of Object)() {1500, 3000, 5000, 4000, 500, 4000} + Dim increasedQuantity_Values As List(Of Object) = New List(Of Object)() {1000, 5000, 4500, 3900, 10000, 8900} + Dim decreasedQuantity_Values As List(Of Object) = New List(Of Object)() {1000, 2000, 3000, 3000, 300, 4000} + + 'Add scenarios in the worksheet with different values for the same cells + scenarios.Add("Current % of Change", worksheet.Range("F5:F10"), currentChangePercentage_Values) + scenarios.Add("Increased % of Change", worksheet.Range("F5:F10"), increasedChangePercentage_Values) + scenarios.Add("Decreased % of Change", worksheet.Range("F5:F10"), decreasedChangePercentage_Values) + scenarios.Add("Current Quantity", worksheet.Range("D5:D10"), currentQuantity_Values) + scenarios.Add("Increased Quantity", worksheet.Range("D5:D10"), increasedQuantity_Values) + scenarios.Add("Decreased Quantity", worksheet.Range("D5:D10"), decreasedQuantity_Values) 'Saving the workbook workbook.SaveAs("Output.xlsx") @@ -86,11 +114,15 @@ End Using {% endhighlight %} {% endtabs %} -Create Scenario Manager +A complete working example to create scenarios in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/What-If%20Analysis/Create%20Scenarios). + +By executing the program, you will get the Excel file as below. + +Create Scenarios ### Edit Scenario -The changing cells range and values of the scenario can be edited by using the **ModifyScenario** method. +An existing scenario can be edited or modified through [ModifyScenario](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenario.html#Syncfusion_XlsIO_IScenario_ModifyScenario_Syncfusion_XlsIO_IRange_System_Collections_Generic_List_System_Object__) method of [IScenario](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenario.html). {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -103,12 +135,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario1 = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); - - List values2 = new List { 2500, 1000, 1500, 1200, 700, 500 }; - IScenario scenario2 = scenarios.Add("Scenario2", worksheet.Range["B3: B8"], values2); + IScenario scenario1 = scenarios[0]; + IScenario scenario2 = scenarios[1]; //Modify the scenario scenario1.ModifyScenario(scenario2.ChangingCells, scenario2.Values); @@ -129,12 +157,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario1 = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); - - List values2 = new List { 2500, 1000, 1500, 1200, 700, 500 }; - IScenario scenario2 = scenarios.Add("Scenario2", worksheet.Range["B3: B8"], values2); + IScenario scenario1 = scenarios[0]; + IScenario scenario2 = scenarios[1]; //Modify the scenario scenario1.ModifyScenario(scenario2.ChangingCells, scenario2.Values); @@ -153,12 +177,8 @@ Using excelEngine As ExcelEngine = New ExcelEngine Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim scenarios As IScenarios = worksheet.Scenarios - 'Add scenarios in the worksheet - Dim values1 As New List(Of Object) From {3000, 2000, 1000, 1600, 500, 1000, 30000} - Dim scenario1 As IScenario = scenarios.Add("Scenario1", worksheet.Range("B3:B9"), values1) - - Dim values2 As New List(Of Object) From {2500, 1000, 1500, 1200, 700, 500} - Dim scenario2 As IScenario = scenarios.Add("Scenario2", worksheet.Range("B3:B8"), values2) + Dim scenario1 As IScenario = scenarios(0) + Dim scenario2 As IScenario = scenarios(1) 'Modify the scenario scenario1.ModifyScenario(scenario2.ChangingCells, scenario2.Values) @@ -171,7 +191,7 @@ End Using ### Delete Scenario -Remove the existing scenario from the scenarios collection by using the **Delete** method. +A scenario can be deleted from the Excel worksheet through [Delete](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenario.html#Syncfusion_XlsIO_IScenario_Delete) method of [IScenario](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenario.html). {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -184,16 +204,10 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - - //Add scenario in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario1 = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); - - List values2 = new List { 2500, 1000, 1500, 1200, 700, 500, 40000 }; - IScenario scenario2 = scenarios.Add("Scenario2", worksheet.Range["B3:B9"], values2); + IScenario scenario1 = scenarios[0]; //Delete the scenario - scenario2.Delete(); + scenario1.Delete(); //Saving the workbook as stream FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); @@ -211,16 +225,11 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario1 = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); - - List values2 = new List { 2500, 1000, 1500, 1200, 700, 500, 40000 }; - IScenario scenario2 = scenarios.Add("Scenario2", worksheet.Range["B3:B9"], values2); + IScenario scenario1 = scenarios[0]; + IScenario scenario2 = scenarios[1]; //Delete the scenario - scenario2.Delete(); + scenario1.Delete(); //Saving the workbook workbook.SaveAs("Output.xlsx"); @@ -236,16 +245,10 @@ Using excelEngine As ExcelEngine = New ExcelEngine Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim scenarios As IScenarios = worksheet.Scenarios - - 'Add scenario in the worksheet - Dim values1 As New List(Of Object) From {3000, 2000, 1000, 1600, 500, 1000, 30000} - Dim scenario1 As IScenario = scenarios.Add("Scenario1", worksheet.Range("B3:B9"), values1) - - Dim values2 As New List(Of Object) From {2500, 1000, 1500, 1200, 700, 500, 40000} - Dim scenario2 As IScenario = scenarios.Add("Scenario2", worksheet.Range("B3:B9"), values2) + Dim scenario1 As IScenario = scenarios(0) 'Delete the scenario - scenario2.Delete() + scenario1.Delete() 'Saving the workbook workbook.SaveAs("Output.xlsx") @@ -255,7 +258,7 @@ End Using ### Merge Scenario -Merges the scenarios from another sheet into the current sheet's scenarios collection by using the **Merge** method. +Scenarios in one Excel worksheet can be merged in to another, using [Merge](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenarios.html#Syncfusion_XlsIO_IScenarios_Merge_Syncfusion_XlsIO_IWorksheet_) method of [IScenarios](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenarios.html). {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -268,16 +271,6 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet1 = workbook.Worksheets[0]; IWorksheet worksheet2 = workbook.Worksheets[1]; - IScenarios scenarios1 = worksheet1.Scenarios; - //Add scenario in the first worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario1 = scenarios1.Add("Scenario1", worksheet1.Range["B3:B9"], values1); - - IScenarios scenarios2 = worksheet2.Scenarios; - //Add scenario in the second worksheet - List values2 = new List { 500, 1000, 1500, 1200, 700, 500, 40000 }; - IScenario scenario2 = scenarios2.Add("Scenario2", worksheet2.Range["B3:B9"], values2); - //Merge the second worksheet scenario into first worksheet. worksheet1.Scenarios.Merge(worksheet2); @@ -297,16 +290,6 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet1 = workbook.Worksheets[0]; IWorksheet worksheet2 = workbook.Worksheets[1]; - IScenarios scenarios1 = worksheet1.Scenarios; - //Add scenario in the first worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario1 = scenarios1.Add("Scenario1", worksheet1.Range["B3:B9"], values1); - - IScenarios scenarios2 = worksheet2.Scenarios; - //Add scenario in the second worksheet - List values2 = new List { 500, 1000, 1500, 1200, 700, 500, 40000 }; - IScenario scenario2 = scenarios2.Add("Scenario2", worksheet2.Range["B3:B9"], values2); - //Merge the second worksheet scenario into first worksheet. worksheet1.Scenarios.Merge(worksheet2); @@ -324,16 +307,6 @@ Using excelEngine As ExcelEngine = New ExcelEngine Dim worksheet1 As IWorksheet = workbook.Worksheets(0) Dim worksheet2 As IWorksheet = workbook.Worksheets(1) - Dim scenarios1 As IScenarios = worksheet1.Scenarios - 'Add scenario in the first worksheet - Dim values1 As New List(Of Object) From {3000, 2000, 1000, 1600, 500, 1000, 30000} - Dim scenario1 As IScenario = scenarios1.Add("Scenario1", worksheet1.Range("B3:B9"), values1) - - Dim scenarios2 As IScenarios = worksheet2.Scenarios - 'Add scenario in the second worksheet - Dim values2 As New List(Of Object) From {2500, 1000, 1500, 1200, 700, 500, 40000} - Dim scenario2 As IScenario = scenarios2.Add("Scenario2", worksheet2.Range("B3:B9"), values2) - 'Merge the second worksheet scenario into first worksheet. worksheet1.Scenarios.Merge(worksheet2) @@ -345,7 +318,7 @@ End Using ### Create Summary -Creates a new worksheet that contains a summary report for the scenarios on the specified worksheet by using **CreateSummary** method. +[CreateSummary](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenarios.html#Syncfusion_XlsIO_IScenarios_CreateSummary_Syncfusion_XlsIO_IRange_) method of [IScenarios](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenarios.html) creates a new worksheet that contains a summary report for the scenarios on the specified worksheet. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -358,18 +331,25 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario1 = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); - - List values2 = new List { 2500, 1000, 1500, 1200, 700, 500, 40000 }; - IScenario scenario2 = scenarios.Add("Scenario2", worksheet.Range["B3:B9"], values2); - List values3 = new List { 1000, 500, 2000, 800, 1300, 1500, 35000 }; - IScenario scenario3 = scenarios.Add("Scenario3", worksheet.Range["B3:B9"], values3); - - //Create Summary for the sheet1 - scenarios.CreateSummary(worksheet.Range["B11"]); + //Initialize list objects with different values for scenarios + List currentChangePercentage_Values = new List { 0.23, 0.8, 1.1, 0.5, 0.35, 0.2}; + List increasedChangePercentage_Values = new List { 0.45, 0.56, 0.9, 0.5, 0.58, 0.43}; + List decreasedChangePercentage_Values = new List { 0.3, 0.2, 0.5, 0.3, 0.5, 0.23}; + List currentQuantity_Values = new List { 1500, 3000, 5000, 4000, 500, 4000 }; + List increasedQuantity_Values = new List { 1000, 5000, 4500, 3900, 10000, 8900 }; + List decreasedQuantity_Values = new List { 1000, 2000, 3000, 3000, 300, 4000 }; + + //Add scenarios in the worksheet with different values for the same cells + scenarios.Add("Current % of Change", worksheet.Range["F5:F10"], currentChangePercentage_Values); + scenarios.Add("Increased % of Change", worksheet.Range["F5:F10"], increasedChangePercentage_Values); + scenarios.Add("Decreased % of Change", worksheet.Range["F5:F10"], decreasedChangePercentage_Values); + scenarios.Add("Current Quantity", worksheet.Range["D5:D10"], currentQuantity_Values); + scenarios.Add("Increased Quantity", worksheet.Range["D5:D10"], increasedQuantity_Values); + scenarios.Add("Decreased Quantity", worksheet.Range["D5:D10"], decreasedQuantity_Values); + + //Create Summary + worksheet.Scenarios.CreateSummary(worksheet.Range["L7"]); //Saving the workbook as stream FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); @@ -387,18 +367,25 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario1 = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); - - List values2 = new List { 2500, 1000, 1500, 1200, 700, 500, 40000 }; - IScenario scenario2 = scenarios.Add("Scenario2", worksheet.Range["B3:B9"], values2); - List values3 = new List { 1000, 500, 2000, 800, 1300, 1500, 35000 }; - IScenario scenario3 = scenarios.Add("Scenario3", worksheet.Range["B3:B9"], values3); - - //Create Summary for the sheet1 - scenarios.CreateSummary(worksheet.Range["B11"]); + //Initialize list objects with different values for scenarios + List currentChangePercentage_Values = new List { 0.23, 0.8, 1.1, 0.5, 0.35, 0.2}; + List increasedChangePercentage_Values = new List { 0.45, 0.56, 0.9, 0.5, 0.58, 0.43}; + List decreasedChangePercentage_Values = new List { 0.3, 0.2, 0.5, 0.3, 0.5, 0.23}; + List currentQuantity_Values = new List { 1500, 3000, 5000, 4000, 500, 4000 }; + List increasedQuantity_Values = new List { 1000, 5000, 4500, 3900, 10000, 8900 }; + List decreasedQuantity_Values = new List { 1000, 2000, 3000, 3000, 300, 4000 }; + + //Add scenarios in the worksheet with different values for the same cells + scenarios.Add("Current % of Change", worksheet.Range["F5:F10"], currentChangePercentage_Values); + scenarios.Add("Increased % of Change", worksheet.Range["F5:F10"], increasedChangePercentage_Values); + scenarios.Add("Decreased % of Change", worksheet.Range["F5:F10"], decreasedChangePercentage_Values); + scenarios.Add("Current Quantity", worksheet.Range["D5:D10"], currentQuantity_Values); + scenarios.Add("Increased Quantity", worksheet.Range["D5:D10"], increasedQuantity_Values); + scenarios.Add("Decreased Quantity", worksheet.Range["D5:D10"], decreasedQuantity_Values); + + //Create Summary + worksheet.Scenarios.CreateSummary(worksheet.Range["L7"]); //Saving the workbook workbook.SaveAs("Output.xlsx"); @@ -414,18 +401,24 @@ Using excelEngine As ExcelEngine = New ExcelEngine Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim scenarios As IScenarios = worksheet.Scenarios - 'Add scenarios in the worksheet - Dim values1 As New List(Of Object) From {3000, 2000, 1000, 1600, 500, 1000, 30000} - Dim scenario1 As IScenario = scenarios.Add("Scenario1", worksheet.Range("B3:B9"), values1) - Dim values2 As New List(Of Object) From {2500, 1000, 1500, 1200, 700, 500, 40000} - Dim scenario2 As IScenario = scenarios.Add("Scenario2", worksheet.Range("B3:B9"), values2) + Dim currentChangePercentage_Values As List(Of Object) = New List(Of Object)() {0.23, 0.8, 1.1, 0.5, 0.35, 0.2} + Dim increasedChangePercentage_Values As List(Of Object) = New List(Of Object)() {0.45, 0.56, 0.9, 0.5, 0.58, 0.43} + Dim decreasedChangePercentage_Values As List(Of Object) = New List(Of Object)() {0.3, 0.2, 0.5, 0.3, 0.5, 0.23} + Dim currentQuantity_Values As List(Of Object) = New List(Of Object)() {1500, 3000, 5000, 4000, 500, 4000} + Dim increasedQuantity_Values As List(Of Object) = New List(Of Object)() {1000, 5000, 4500, 3900, 10000, 8900} + Dim decreasedQuantity_Values As List(Of Object) = New List(Of Object)() {1000, 2000, 3000, 3000, 300, 4000} - Dim values3 As New List(Of Object) From {1000, 500, 2000, 800, 1300, 1500, 35000} - Dim scenario3 As IScenario = scenarios.Add("Scenario3", worksheet.Range("B3:B9"), values3) + 'Add scenarios in the worksheet with different values for the same cells + scenarios.Add("Current % of Change", worksheet.Range("F5:F10"), currentChangePercentage_Values) + scenarios.Add("Increased % of Change", worksheet.Range("F5:F10"), increasedChangePercentage_Values) + scenarios.Add("Decreased % of Change", worksheet.Range("F5:F10"), decreasedChangePercentage_Values) + scenarios.Add("Current Quantity", worksheet.Range("D5:D10"), currentQuantity_Values) + scenarios.Add("Increased Quantity", worksheet.Range("D5:D10"), increasedQuantity_Values) + scenarios.Add("Decreased Quantity", worksheet.Range("D5:D10"), decreasedQuantity_Values) - 'Create Summary for the sheet1 - scenarios.CreateSummary(worksheet.Range("B11")) + 'Create Summary + worksheet.Scenarios.CreateSummary(worksheet.Range("L7")) 'Saving the workbook workbook.SaveAs("Output.xlsx") @@ -433,11 +426,11 @@ End Using {% endhighlight %} {% endtabs %} -Create Scenario Manager +Create Summary ### Apply Scenario -Update the scenario values in the worksheet and display it using the **Show** method. +Update the scenario values in the worksheet and display it using the [Show](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenario.html#Syncfusion_XlsIO_IScenario_Show) method. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -448,14 +441,10 @@ using (ExcelEngine excelEngine = new ExcelEngine()) FileStream inputStream = new FileStream("InputTemplate.xlsx", FileMode.Open, FileAccess.Read); IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); IWorksheet worksheet = workbook.Worksheets[0]; - - IScenarios scenarios = worksheet.Scenarios; - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario1 = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); - List values2 = new List { 2500, 1000, 1500, 1200, 700, 500, 40000 }; - IScenario scenario2 = scenarios.Add("Scenario2", worksheet.Range["B3:B9"], values2); + IScenarios scenarios = worksheet.Scenarios; + IScenario scenario1 = scenarios[0]; + IScenario scenario2 = scenarios[1]; //Show the scenario scenario2.Show(); @@ -476,12 +465,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario1 = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); - - List values2 = new List { 2500, 1000, 1500, 1200, 700, 500, 40000 }; - IScenario scenario2 = scenarios.Add("Scenario2", worksheet.Range["B3:B9"], values2); + IScenario scenario1 = scenarios[0]; + IScenario scenario2 = scenarios[1]; //Show the scenario scenario2.Show(); @@ -500,12 +485,8 @@ Using excelEngine As ExcelEngine = New ExcelEngine Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim scenarios As IScenarios = worksheet.Scenarios - 'Add scenarios in the worksheet - Dim values1 As New List(Of Object) From {3000, 2000, 1000, 1600, 500, 1000, 30000} - Dim scenario1 As IScenario = scenarios.Add("Scenario1", worksheet.Range("B3:B9"), values1) - - Dim values2 As New List(Of Object) From {2500, 1000, 1500, 1200, 700, 500, 40000} - Dim scenario2 As IScenario = scenarios.Add("Scenario2", worksheet.Range("B3:B9"), values2) + Dim scenario1 As IScenario = scenarios(0) + Dim scenario2 As IScenario = scenarios(1) 'Show the scenario scenario2.Show() @@ -516,9 +497,11 @@ End Using {% endhighlight %} {% endtabs %} +A complete working example to show scenario in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/What-If%20Analysis/Apply%20Scenario). + ### Set Name -The name of the scenario can be defined using the **Name** property.. +The name of the scenario can be defined using the [Name](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenario.html#Syncfusion_XlsIO_IScenario_Name) property.. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -531,12 +514,10 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); + IScenario scenario = scenarios[0]; //Set the name of the scenario - scenario.Name = "ScenarioNameChanged"; + scenario.Name = "Current Quantity"; //Saving the workbook as stream FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); @@ -554,12 +535,10 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); + IScenario scenario = scenarios[0]; //Set the name of the scenario - scenario.Name = "ScenarioNameChanged"; + scenario.Name = "Current Quantity"; //Saving the workbook workbook.SaveAs("Output.xlsx"); @@ -575,12 +554,10 @@ Using excelEngine As ExcelEngine = New ExcelEngine Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim scenarios As IScenarios = worksheet.Scenarios - 'Add scenarios in the worksheet - Dim values1 As New List(Of Object) From {3000, 2000, 1000, 1600, 500, 1000, 30000} - Dim scenario As IScenario = scenarios.Add("Scenario1", worksheet.Range("B3:B9"), values1) + Dim scenario As IScenario = scenarios(0) 'Set the name of the scenario - scenario.Name = "ScenarioNameChanged" + scenario.Name = "Current Quantity" 'Saving the workbook workbook.SaveAs("Output.xlsx") End Using @@ -589,7 +566,7 @@ End Using ### Hide Scenario -The scenario can be hidden using the **Hidden** property. It is a boolean property, with its default value set to false. +The scenario can be hidden by enabling the [Hidden](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenario.html#Syncfusion_XlsIO_IScenario_Hidden) property of [IScenario](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenario.html). {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -602,9 +579,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); + IScenario scenario = scenarios[0]; //Hidden the scenario scenario.Hidden = true; @@ -625,9 +600,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); + IScenario scenario = scenarios[0]; //Hidden the scenario scenario.Hidden = true; @@ -646,9 +619,7 @@ Using excelEngine As ExcelEngine = New ExcelEngine Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim scenarios As IScenarios = worksheet.Scenarios - 'Add the scenarios in the worksheet - Dim values1 As New List(Of Object) From {3000, 2000, 1000, 1600, 500, 1000, 30000} - Dim scenario As IScenario = scenarios.Add("Scenario1", worksheet.Range("B3:B9"), values1) + Dim scenario As IScenario = scenarios(0) 'Hidden the scenario scenario.Hidden = True @@ -659,9 +630,11 @@ End Using {% endhighlight %} {% endtabs %} +A complete working example to hide a scenario in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/What-If%20Analysis/Hide%20Scenario). + ### Protect Scenario -The scenario can be locked using the **Locked** property. It is a boolean property, with its default value set to true. +The scenario can be locked or unlocked through [Locked](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenario.html#Syncfusion_XlsIO_IScenario_Locked) property of [IScenario](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenario.html). A scenario is locked by default. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -674,11 +647,9 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); + IScenario scenario = scenarios[0]; - //Set the scenario to be locked + //Unlock a scenario scenario.Locked = false; //Saving the workbook as stream @@ -697,11 +668,9 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); + IScenario scenario = scenarios[0]; - //Set the scenario to be locked + //Unlock a scenario scenario.Locked = false; //Saving the workbook @@ -718,11 +687,9 @@ Using excelEngine As ExcelEngine = New ExcelEngine Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim scenarios As IScenarios = worksheet.Scenarios - 'Add scenarios in the worksheet - Dim values1 As New List(Of Object) From {3000, 2000, 1000, 1600, 500, 1000, 30000} - Dim scenario As IScenario = scenarios.Add("Scenario1", worksheet.Range("B3:B9"), values1) + Dim scenario As IScenario = scenarios(0) - 'Set the scenario to be locked + 'Unlock a scenario scenario.Locked = False 'Saving the workbook @@ -732,9 +699,11 @@ End Using {% endhighlight %} {% endtabs %} +A complete working example to unprotect a scenario in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/What-If%20Analysis/Protect%20Scenario). + ### Add Comment -The comment associated with that particular scenario can be generated using the **Comment** property. +The comment associated with that particular scenario can be generated using the [Comment](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IScenario.html#Syncfusion_XlsIO_IScenario_Comment) property. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -747,12 +716,10 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - //Add scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); + IScenario scenario = scenarios[0]; //Set the comment value - scenario.Comment = "Scenario 1 can be created"; + scenario.Comment = "Scenario has been created"; //Saving the workbook as stream FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); @@ -770,12 +737,10 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorksheet worksheet = workbook.Worksheets[0]; IScenarios scenarios = worksheet.Scenarios; - //Add the scenarios in the worksheet - List values1 = new List { 3000, 2000, 1000, 1600, 500, 1000, 30000 }; - IScenario scenario = scenarios.Add("Scenario1", worksheet.Range["B3:B9"], values1); + IScenario scenario = scenarios[0]; //Set the comment value - scenario.Comment = "Scenario 1 can be created"; + scenario.Comment = "Scenario has been created"; //Saving the workbook workbook.SaveAs("Output.xlsx"); @@ -791,12 +756,10 @@ Using excelEngine As ExcelEngine = New ExcelEngine Dim worksheet As IWorksheet = workbook.Worksheets(0) Dim scenarios As IScenarios = worksheet.Scenarios - 'Add the scenarios in the worksheet - Dim values1 As New List(Of Object) From {3000, 2000, 1000, 1600, 500, 1000, 30000} - Dim scenario As IScenario = scenarios.Add("Scenario1", worksheet.Range("B3:B9"), values1) + Dim scenario As IScenario = scenarios[0] 'Set the comment value - scenario.Comment = "Scenario 1 can be created" + scenario.Comment = "Scenario has been created" 'Saving the workbook workbook.SaveAs("Output.xlsx") diff --git a/File-Formats/XlsIO/What_If_Analysis_images/Create_Scenario.png b/File-Formats/XlsIO/What_If_Analysis_images/Create_Scenario.png index 89c90f623..f88124b28 100644 Binary files a/File-Formats/XlsIO/What_If_Analysis_images/Create_Scenario.png and b/File-Formats/XlsIO/What_If_Analysis_images/Create_Scenario.png differ diff --git a/File-Formats/XlsIO/What_If_Analysis_images/Create_Summary.png b/File-Formats/XlsIO/What_If_Analysis_images/Create_Summary.png index 86a7bc158..ddce97446 100644 Binary files a/File-Formats/XlsIO/What_If_Analysis_images/Create_Summary.png and b/File-Formats/XlsIO/What_If_Analysis_images/Create_Summary.png differ diff --git a/File-Formats/XlsIO/Working-with-Drawing-Objects.md b/File-Formats/XlsIO/Working-with-Drawing-Objects.md index 7ef66d8c9..3e0a025ec 100644 --- a/File-Formats/XlsIO/Working-with-Drawing-Objects.md +++ b/File-Formats/XlsIO/Working-with-Drawing-Objects.md @@ -876,11 +876,11 @@ A complete working example to remove comment in C# is present on [this GitHub pa ## Threaded Comments -Threaded comments are a way to add and organize annotations or discussions related to specific cells in a worksheet.**IThreadedComment** object represents a threaded comment in a worksheet. +Threaded comments are a way to add and organize annotations or discussions related to specific cells in a worksheet. [IThreadedComment](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IThreadedComment.html) object represents a threaded comment in a worksheet. ### Create -The following code explains how to create a threaded comment for a specific cell with the specified text using **AddThreadedComment** method. +The following code explains how to create a threaded comment for a specific cell using [AddThreadedComment](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IRange.html#Syncfusion_XlsIO_IRange_AddThreadedComment_System_String_System_String_System_DateTime_) method. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -892,8 +892,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); IWorksheet worksheet = workbook.Worksheets[0]; - //Add threaded comments - IThreadedComment threadedComment = worksheet.Range["H16"].AddThreadedComment("What is the reason for the higher total amount of \"desk\" in the west region?", "User1", DateTime.Now); + //Add threaded comment + worksheet.Range["H16"].AddThreadedComment("What is the reason for the higher total amount of \"desk\" in the west region?", "User1", DateTime.Now); //Saving the workbook as stream FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); @@ -910,8 +910,8 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorkbook workbook = application.Workbooks.Open("CommentsTemplate.xlsx", ExcelOpenType.Automatic); IWorksheet worksheet = workbook.Worksheets[0]; - //Add threaded comments - IThreadedComment threadedComment = worksheet.Range["H16"].AddThreadedComment("What is the reason for the higher total amount of \"desk\" in the west region?", "User1", DateTime.Now); + //Add threaded comment + worksheet.Range["H16"].AddThreadedComment("What is the reason for the higher total amount of \"desk\" in the west region?", "User1", DateTime.Now); //Saving the workbook workbook.SaveAs("Ouptput.xlsx"); @@ -927,7 +927,7 @@ Using excelEngine As ExcelEngine = New ExcelEngine Dim worksheet As IWorksheet = workbook.Worksheets(0) 'Add threaded comment - Dim threadedComment As IThreadedComment = worksheet.Range("H16").AddThreadedComment("What is the reason for the higher total amount of ""desk"" in the west region?", "User1", DateTime.Now) + worksheet.Range("H16").AddThreadedComment("What is the reason for the higher total amount of ""desk"" in the west region?", "User1", DateTime.Now) 'Saving the workbook workbook.SaveAs("Output.xlsx") @@ -935,9 +935,11 @@ End Using {% endhighlight %} {% endtabs %} +A complete working example to create a threaded comment in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Threaded%20Comments/Add%20Comment). + ### Reply -The following code adds a replies to an existing threaded comment with specific text using the **AddReply** method. +The following code adds a replies to an existing threaded comment using the [AddReply](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IThreadedComment.html#Syncfusion_XlsIO_IThreadedComment_AddReply_System_String_System_String_System_DateTime_) method of [IThreadedComment](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IThreadedComment.html). {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -949,12 +951,9 @@ using (ExcelEngine excelEngine = new ExcelEngine()) IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic); IWorksheet worksheet = workbook.Worksheets[0]; - //Add Threaded Comment - IThreadedComment threadedComment = worksheet.Range["H16"].AddThreadedComment("What is the reason for the higher total amount of \"desk\" in the west region?", "User1", DateTime.Now); - - //Add Reply to the threaded comement - threadedComment.AddReply("The unit cost of desk is higher compared to other items in the west region. As a result, the total amount is elevated.", "User2", DateTime.Now); - threadedComment.AddReply("Additionally, Wilson sold 31 desks in the west region, which is also a contributing factor to the increased total amount.", "User3", DateTime.Now); + //Add replies to the threaded comement + worksheet.Range["H16"].ThreadedComment.AddReply("The unit cost of desk is higher compared to other items in the west region. As a result, the total amount is elevated.", "User2", DateTime.Now); + worksheet.Range["H16"].ThreadedComment.AddReply("Additionally, Wilson sold 31 desks in the west region, which is also a contributing factor to the increased total amount.", "User3", DateTime.Now); //Saving the workbook as stream FileStream stream = new FileStream("Output.xlsx", FileMode.Create, FileAccess.ReadWrite); @@ -970,13 +969,10 @@ using (ExcelEngine excelEngine = new ExcelEngine()) application.DefaultVersion = ExcelVersion.Xlsx; IWorkbook workbook = application.Workbooks.Open("CommentsTemplate.xlsx", ExcelOpenType.Automatic); IWorksheet worksheet = workbook.Worksheets[0]; - - //Add Threaded Comment - IThreadedComment threadedComment = worksheet.Range["H16"].AddThreadedComment("What is the reason for the higher total amount of \"desk\" in the west region?", "User1", DateTime.Now); - //Add Reply to the threaded comement - threadedComment.AddReply("The unit cost of desk is higher compared to other items in the west region. As a result, the total amount is elevated.", "User2", DateTime.Now); - threadedComment.AddReply("Additionally, Wilson sold 31 desks in the west region, which is also a contributing factor to the increased total amount.", "User3", DateTime.Now); + //Add replies to the threaded comement + worksheet.Range["H16"].ThreadedComment.AddReply("The unit cost of desk is higher compared to other items in the west region. As a result, the total amount is elevated.", "User2", DateTime.Now); + worksheet.Range["H16"].ThreadedComment.AddReply("Additionally, Wilson sold 31 desks in the west region, which is also a contributing factor to the increased total amount.", "User3", DateTime.Now); //Saving the workbook workbook.SaveAs("Output.xlsx"); @@ -991,12 +987,9 @@ Using excelEngine As ExcelEngine = New ExcelEngine Dim workbook As IWorkbook = application.Workbooks.Open("CommentsTemplate.xlsx", ExcelOpenType.Automatic) Dim worksheet As IWorksheet = workbook.Worksheets(0) - 'Add threaded comment - Dim threadedComment As IThreadedComment = worksheet.Range("H16").AddThreadedComment("What is the reason for the higher total amount of ""desk"" in the west region?", "User1", DateTime.Now) - - 'Add Reply to the threaded comement - threadedComment.AddReply("The unit cost of desk is higher compared to other items in the west region. As a result, the total amount is elevated.", "User2", DateTime.Now) - threadedComment.AddReply("Additionally, Wilson sold 31 desks in the west region, which is also a contributing factor to the increased total amount.", "User3", DateTime.Now) + 'Add replies to the threaded comement + worksheet.Range("H16").ThreadedComment.AddReply("The unit cost of desk is higher compared to other items in the west region. As a result, the total amount is elevated.", "User2", DateTime.Now) + worksheet.Range("H16").ThreadedComment.AddReply("Additionally, Wilson sold 31 desks in the west region, which is also a contributing factor to the increased total amount.", "User3", DateTime.Now) 'Saving the workbook workbook.SaveAs("Output.xlsx") @@ -1004,12 +997,14 @@ End Using {% endhighlight %} {% endtabs %} -The following screenshot represents the output Excel file of threaded comments generated by the XlsIO -output Excel file +A complete working example to add replies in a existing threaded comment in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Threaded%20Comments/Reply%20Comment). + +The following screenshot represents the output Excel file of threaded comments generated by the XlsIO. +Threaded Comments ### Mark as resolved -The threaded comment discussion can be marked as resolved by using the **IsResolved** property. By default, it is set to **false**. +The threaded comment discussion can be marked as resolved by enabling the [IsResolved](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IThreadedComment.html#Syncfusion_XlsIO_IThreadedComment_IsResolved) property. By default, the value is set to **false**. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -1073,9 +1068,11 @@ End Using {% endhighlight %} {% endtabs %} +A complete working example to mark a treaded comment as resolved in C# is present on [this GitHub page](https://github.com/SyncfusionExamples/XlsIO-Examples/tree/master/Threaded%20Comments/Resolve%20Comment). + ### Delete -The following code deletes a threaded comment from the collection of threaded comments using the **Delete** method. +The following code shows how to delete a threaded comment from the collection of threaded comments using the [Delete](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IThreadedComment.html#Syncfusion_XlsIO_IThreadedComment_Delete) method. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -1141,7 +1138,7 @@ End Using ### Clear -The following code clears all the threaded comments from the threaded comments collection using the **Clear** method. +The following code clears all the threaded comments in the worksheet using the [Clear](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IThreadedComments.html#Syncfusion_XlsIO_IThreadedComments_Clear) method of [IThreadedComments](https://help.syncfusion.com/cr/file-formats/Syncfusion.XlsIO.IThreadedComments.html). {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} @@ -1156,7 +1153,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Get the collection of threaded comments in the worksheet IThreadedComments threadedComments = worksheet.ThreadedComments; - //clear all the threaded comment from the threaded comments collection + //Clear all the threaded comments threadedComments.Clear(); //Saving the workbook as stream @@ -1177,7 +1174,7 @@ using (ExcelEngine excelEngine = new ExcelEngine()) //Get the collection of threaded comments in the worksheet IThreadedComments threadedComments = worksheet.ThreadedComments; - //clear all the threaded comment from the threaded comments collection + //Clear all the threaded comments threadedComments.Clear(); //Saving the workbook @@ -1196,7 +1193,7 @@ Using excelEngine As ExcelEngine = New ExcelEngine 'Get the collection of threaded comments in the worksheet Dim threadedComments As IThreadedComments = worksheet.ThreadedComments - 'clear all the threaded comment from the threaded comments collection + 'Clear all the threaded comments threadedComments.Clear() 'Saving the workbook