Syncfusion.XlsIO.Base
Example 


PercentMax Property

Gets or sets a value that specifies the length of the longest data bar as a percentage of cell width.
Syntax
'Declaration
 
Property PercentMax As Integer
'Usage
 
Dim instance As IDataBar
Dim value As Integer
 
instance.PercentMax = value
 
value = instance.PercentMax
int PercentMax {get; set;}
Remarks
To set minimum length of the DataBar refer PercentMin property.
Example
By default the DataBar's PercentMax and PercentMin are set to 100 and 0 respectively. This allows the DataBar to begin from the starting position zero to the entire cell width. We can customize the appearance of DataBars by changing these two properties. Here for example, we set the PercentMax property's value to 80. This sets the DataBars maximum lenght to 80 percent.
using Syncfusion.XlsIO;
            
class Example
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            //Create a worksheet.        
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;            
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
            
            //Load data to Apply Conditional Formatting.
            worksheet["A1"].Text = "DataBar";
            worksheet["A2"].Number = 10;
            worksheet["A3"].Number = 20;
            worksheet["A4"].Number = 30;
            worksheet["A5"].Number = 40;
            worksheet["A6"].Number = 50;
            worksheet["A7"].Number = 60;
            worksheet["A8"].Number = 70;
            worksheet["A9"].Number = 80;
            worksheet["A10"].Number = 90;
            worksheet["A11"].Number = 100;
            
            //Create instance of IConditonalFormat and IConditionalFormats.
            IConditionalFormats formats = worksheet["A2:A11"].ConditionalFormats;
            IConditionalFormat format = formats.AddCondition();
            
            //Set FormatType as DataBar.
            format.FormatType = ExcelCFType.DataBar;
            IDataBar dataBar = format.DataBar;
            
            //Set maximum percentage.
            dataBar.PercentMax = 80;
            
            //Save and Dispose.
            workbook.SaveAs("ConditionalFormats.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.1460.0.32

See Also