From 93427b3ec9ed89698796e4fa78a692eea380c295 Mon Sep 17 00:00:00 2001 From: KurmithaSF4004 Date: Wed, 29 May 2024 18:14:34 +0530 Subject: [PATCH] 888375-CF-GradientFill-XlsIO --- .../Top To Bottom Percent/Program.cs | 47 +++++++++---- .../Top to Bottom Rank/Program.cs | 40 ++++++++--- .../Unique and Duplicate/Program.cs | 66 ++++++++++++++----- 3 files changed, 119 insertions(+), 34 deletions(-) diff --git a/Conditional Formatting/Top To Bottom Percent/NET Standard/Top To Bottom Percent/Top To Bottom Percent/Program.cs b/Conditional Formatting/Top To Bottom Percent/NET Standard/Top To Bottom Percent/Top To Bottom Percent/Program.cs index f3fc1355..289bd7fa 100644 --- a/Conditional Formatting/Top To Bottom Percent/NET Standard/Top To Bottom Percent/Top To Bottom Percent/Program.cs +++ b/Conditional Formatting/Top To Bottom Percent/NET Standard/Top To Bottom Percent/Top To Bottom Percent/Program.cs @@ -16,28 +16,53 @@ static void Main(string[] args) IWorksheet worksheet = workbook.Worksheets[0]; //Applying conditional formatting to "N6:N35". - IConditionalFormats formats = worksheet.Range["N6:N35"].ConditionalFormats; - IConditionalFormat format = formats.AddCondition(); + IConditionalFormats conditionalFormats1 = worksheet.Range["N6:N35"].ConditionalFormats; + IConditionalFormat conditionalFormat1 = conditionalFormats1.AddCondition(); //Applying top or bottom rule in the conditional formatting. - format.FormatType = ExcelCFType.TopBottom; - ITopBottom topBottom = format.TopBottom; + conditionalFormat1.FormatType = ExcelCFType.TopBottom; + ITopBottom topBottom1 = conditionalFormat1.TopBottom; //Set type as Bottom for TopBottom rule. - topBottom.Type = ExcelCFTopBottomType.Bottom; + topBottom1.Type = ExcelCFTopBottomType.Bottom; //Set true to Percent property for TopBottom rule. - topBottom.Percent = true; + topBottom1.Percent = true; //Set rank value for the TopBottom rule. - topBottom.Rank = 50; + topBottom1.Rank = 50; - //Set color for Conditional Formattting. - format.BackColorRGB = Syncfusion.Drawing.Color.FromArgb(51, 153, 102); + //Set solid color conditional formatting for TopBottom rule. + conditionalFormat1.FillPattern = ExcelPattern.Solid; + conditionalFormat1.BackColorRGB = Syncfusion.Drawing.Color.FromArgb(51, 153, 102); + + //Applying conditional formatting to "M6:M35". + IConditionalFormats conditionalFormats2 = worksheet.Range["M6:M35"].ConditionalFormats; + IConditionalFormat conditionalFormat2 = conditionalFormats2.AddCondition(); + + //Applying top or bottom rule in the conditional formatting. + conditionalFormat2.FormatType = ExcelCFType.TopBottom; + ITopBottom topBottom2 = conditionalFormat2.TopBottom; + + //Set type as Top for TopBottom rule. + topBottom2.Type = ExcelCFTopBottomType.Bottom; + + //Set true to Percent property for TopBottom rule. + topBottom2.Percent = true; + + //Set rank value for the TopBottom rule. + topBottom2.Rank = 20; + + //Set gradient color conditional formatting for TopBottom rule. + conditionalFormat2.FillPattern = ExcelPattern.Gradient; + conditionalFormat2.BackColorRGB = Syncfusion.Drawing.Color.FromArgb(130, 60, 12); + conditionalFormat2.ColorRGB = Syncfusion.Drawing.Color.FromArgb(255, 255, 0); + conditionalFormat2.GradientStyle = ExcelGradientStyle.Horizontal; + conditionalFormat2.GradientVariant = ExcelGradientVariants.ShadingVariants_1; #region Save //Saving the workbook - FileStream outputStream = new FileStream("Chart.xlsx", FileMode.Create, FileAccess.Write); + FileStream outputStream = new FileStream("TopToBottomRank.xlsx", FileMode.Create, FileAccess.Write); workbook.SaveAs(outputStream); #endregion @@ -46,7 +71,7 @@ static void Main(string[] args) inputStream.Dispose(); System.Diagnostics.Process process = new System.Diagnostics.Process(); - process.StartInfo = new System.Diagnostics.ProcessStartInfo("Chart.xlsx") + process.StartInfo = new System.Diagnostics.ProcessStartInfo("TopToBottomRank.xlsx") { UseShellExecute = true }; diff --git a/Conditional Formatting/Top to Bottom Rank/NET Standard/Top to Bottom Rank/Top to Bottom Rank/Program.cs b/Conditional Formatting/Top to Bottom Rank/NET Standard/Top to Bottom Rank/Top to Bottom Rank/Program.cs index 8e65b1de..1da220fd 100644 --- a/Conditional Formatting/Top to Bottom Rank/NET Standard/Top to Bottom Rank/Top to Bottom Rank/Program.cs +++ b/Conditional Formatting/Top to Bottom Rank/NET Standard/Top to Bottom Rank/Top to Bottom Rank/Program.cs @@ -1,5 +1,6 @@ using System.IO; using Syncfusion.XlsIO; +using Syncfusion.XlsIO.Implementation.Collections; namespace Top_to_Bottom_Rank { @@ -16,21 +17,44 @@ static void Main(string[] args) IWorksheet worksheet = workbook.Worksheets[0]; //Applying conditional formatting to "N6:N35". - IConditionalFormats formats = worksheet.Range["N6:N35"].ConditionalFormats; - IConditionalFormat format = formats.AddCondition(); + IConditionalFormats conditionalFormats1 = worksheet.Range["N6:N35"].ConditionalFormats; + IConditionalFormat conditionalFormat1 = conditionalFormats1.AddCondition(); //Applying top or bottom rule in the conditional formatting. - format.FormatType = ExcelCFType.TopBottom; - ITopBottom topBottom = format.TopBottom; + conditionalFormat1.FormatType = ExcelCFType.TopBottom; + ITopBottom topBottom1 = conditionalFormat1.TopBottom; //Set type as Top for TopBottom rule. - topBottom.Type = ExcelCFTopBottomType.Top; + topBottom1.Type = ExcelCFTopBottomType.Top; //Set rank value for the TopBottom rule. - topBottom.Rank = 10; + topBottom1.Rank = 10; - //Set color for Conditional Formattting. - format.BackColorRGB = Syncfusion.Drawing.Color.FromArgb(51, 153, 102); + //Set solid color conditional formatting for TopBottom rule. + conditionalFormat1.FillPattern = ExcelPattern.Solid; + conditionalFormat1.BackColorRGB = Syncfusion.Drawing.Color.FromArgb(51, 153, 102); + + + //Applying conditional formatting to "M6:M35". + IConditionalFormats conditionalFormats2 = worksheet.Range["M6:M35"].ConditionalFormats; + IConditionalFormat conditionalFormat2 = conditionalFormats2.AddCondition(); + + //Applying top or bottom rule in the conditional formatting. + conditionalFormat2.FormatType = ExcelCFType.TopBottom; + ITopBottom topBottom2 = conditionalFormat2.TopBottom; + + //Set type as Top for TopBottom rule. + topBottom2.Type = ExcelCFTopBottomType.Top; + + //Set rank value for the TopBottom rule. + topBottom2.Rank = 10; + + //Set gradient color conditional formatting for TopBottom rule. + conditionalFormat2.FillPattern = ExcelPattern.Gradient; + conditionalFormat2.BackColorRGB = Syncfusion.Drawing.Color.FromArgb(130, 60, 12); + conditionalFormat2.ColorRGB = Syncfusion.Drawing.Color.FromArgb(255, 255, 0); + conditionalFormat2.GradientStyle = ExcelGradientStyle.Horizontal; + conditionalFormat2.GradientVariant = ExcelGradientVariants.ShadingVariants_1; #region Save //Saving the workbook diff --git a/Conditional Formatting/Unique and Duplicate/NET Standard/Unique and Duplicate/Unique and Duplicate/Program.cs b/Conditional Formatting/Unique and Duplicate/NET Standard/Unique and Duplicate/Unique and Duplicate/Program.cs index a8f849a7..9e84279d 100644 --- a/Conditional Formatting/Unique and Duplicate/NET Standard/Unique and Duplicate/Unique and Duplicate/Program.cs +++ b/Conditional Formatting/Unique and Duplicate/NET Standard/Unique and Duplicate/Unique and Duplicate/Program.cs @@ -1,6 +1,8 @@ using System.IO; using Syncfusion.XlsIO; using Syncfusion.Drawing; +using Syncfusion.XlsIO.Implementation.Collections; +using System.Collections.Generic; namespace Unique_and_Duplicate { @@ -11,21 +13,21 @@ static void Main(string[] args) using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; - application.DefaultVersion = ExcelVersion.Excel2016; + application.DefaultVersion = ExcelVersion.Xlsx; IWorkbook workbook = application.Workbooks.Create(1); IWorksheet worksheet = workbook.Worksheets[0]; //Fill worksheet with data - worksheet.Range["A1:B1"].Merge(); - worksheet.Range["A1:B1"].CellStyle.Font.RGBColor = Color.FromArgb(255, 102, 102, 255); - worksheet.Range["A1:B1"].CellStyle.Font.Size = 14; - worksheet.Range["A1:B1"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + worksheet.Range["A1:C1"].Merge(); + worksheet.Range["A1:C1"].CellStyle.Font.RGBColor = Color.FromArgb(255, 102, 102, 255); + worksheet.Range["A1:C1"].CellStyle.Font.Size = 14; + worksheet.Range["A1:C1"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; worksheet.Range["A1"].Text = "Global Internet Usage"; - worksheet.Range["A1:B1"].CellStyle.Font.Bold = true; + worksheet.Range["A1:C1"].CellStyle.Font.Bold = true; - worksheet.Range["A3:B21"].CellStyle.Font.RGBColor = Color.FromArgb(255, 64, 64, 64); - worksheet.Range["A3:B3"].CellStyle.Font.Bold = true; - worksheet.Range["B3"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignRight; + worksheet.Range["A3:C21"].CellStyle.Font.RGBColor = Color.FromArgb(255, 64, 64, 64); + worksheet.Range["A3:C3"].CellStyle.Font.Bold = true; + worksheet.Range["B3:C3"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignRight; worksheet.Range["A3"].Text = "Country"; worksheet.Range["A4"].Text = "Northern America"; @@ -67,16 +69,50 @@ static void Main(string[] args) worksheet.Range["B20"].Value = "58%"; worksheet.Range["B21"].Value = "69%"; + worksheet.Range["C3"].Text = "Connection Count"; + worksheet.Range["C3"].AutofitColumns(); + worksheet.Range["C4"].Number = 1200; + worksheet.Range["C5"].Number = 800; + worksheet.Range["C6"].Number = 600; + worksheet.Range["C7"].Number = 900; + worksheet.Range["C8"].Number = 1500; + worksheet.Range["C9"].Number = 1100; + worksheet.Range["C10"].Number = 1400; + worksheet.Range["C11"].Number = 1000; + worksheet.Range["C12"].Number = 600; + worksheet.Range["C13"].Number = 400; + worksheet.Range["C14"].Number = 300; + worksheet.Range["C15"].Number = 550; + worksheet.Range["C16"].Number = 700; + worksheet.Range["C17"].Number = 610; + worksheet.Range["C18"].Number = 750; + worksheet.Range["C19"].Number = 500; + worksheet.Range["C20"].Number = 750; + worksheet.Range["C21"].Number = 910; + worksheet.SetColumnWidth(1, 23.45); worksheet.SetColumnWidth(2, 8.09); - IConditionalFormats conditionalFormats = - worksheet.Range["A4:B21"].ConditionalFormats; - IConditionalFormat condition = conditionalFormats.AddCondition(); + IConditionalFormats conditionalFormats1 = + worksheet.Range["B4:B21"].ConditionalFormats; + IConditionalFormat condition1 = conditionalFormats1.AddCondition(); + + //Set solid color conditional formatting for duplicate values. + condition1.FormatType = ExcelCFType.Duplicate; + condition1.FillPattern = ExcelPattern.Solid; + condition1.BackColorRGB = Color.FromArgb(255, 255, 199, 206); + + IConditionalFormats conditionalFormats2 = + worksheet.Range["C4:C21"].ConditionalFormats; + IConditionalFormat condition2 = conditionalFormats2.AddCondition(); - //conditional format to set duplicate format type - condition.FormatType = ExcelCFType.Duplicate; - condition.BackColorRGB = Color.FromArgb(255, 255, 199, 206); + //Set gradient color conditional formatting for duplicate values. + condition2.FormatType = ExcelCFType.Duplicate; + condition2.FillPattern = ExcelPattern.Gradient; + condition2.BackColorRGB = Color.FromArgb(255, 255, 199, 206); + condition2.ColorRGB = Color.FromArgb(200, 255, 5, 79); + condition2.GradientStyle = ExcelGradientStyle.Horizontal; + condition2.GradientVariant = ExcelGradientVariants.ShadingVariants_1; #region Save //Saving the workbook