Skip to content

ES-974087-Move the Spreadsheet UG sections from UWP to document process #1131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 76 additions & 3 deletions Document-Processing-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -1789,19 +1789,92 @@
<li>
<a href="/document-processing/excel/spreadsheet/uwp/overview">UWP</a>
<ul>
#ReplaceUsingAutomation-https://github.com/syncfusion-content/uwp-docs/tree/master/uwp/Spreadsheet#
<li>
SfSpreadsheet
<ul>
<li><a href="/document-processing/excel/uwp/Spreadsheet/overview">Overview</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/getting-started">Getting Started</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/working-with-sfspreadsheet">Working With Spreadsheet</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/selection">Selection</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/Editing">Editing</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/formatting">Formatting</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/conditional-formatting">Conditional Formatting</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/formulas">Formulas</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/rows-and-columns">Rows and Columns</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/worksheet-management">Worksheet Management</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/interactive-features">Interactive Features</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/find-and-replace">Find and Replace</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/outline">Outline</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/shapes">Shapes</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/localization">Localization</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/ribbon-customization">Ribbon Customization</a></li>
<li><a href="/document-processing/excel/uwp/Spreadsheet/custom-formula">Custom Formula</a></li>
</ul>
</li>
</ul>
</li>
<li>
<a href="/document-processing/excel/spreadsheet/winforms/overview">Windows Forms</a>
<ul>
#ReplaceUsingAutomation-https://github.com/syncfusion-content/windowsforms-docs/tree/master/WindowsForms/Spreadsheet#
<li>
Spreadsheet
<ul>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/overview">Overview</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/getting-started">Getting Started</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/working-with-spreadsheet">Working With Spreadsheet</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/selection">Selection</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/editing">Editing</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/formatting">Formatting</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/conditional-formatting">Conditional Formatting</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/sorting-and-filtering">Sorting And Filtering</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/formulas">Formulas</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/rows-and-columns">Rows and Columns</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/worksheet-management">Worksheet Management</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/data-management">Data Management</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/interactive-features">Interactive Features</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/find-and-replace">Find and Replace</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/outline">Outline</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/shapes">Shapes</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/conversion">Conversion</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/localization">Localization</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/printing">Printing</a></li>
<li><a href="document-processing/excel/windowsforms/Spreadsheet/custom-formula">Custom Formula</a></li>
</ul>
</li>
</ul>
</li>
<li>
<a href="/document-processing/excel/spreadsheet/wpf/overview">WPF</a>
<ul>
#ReplaceUsingAutomation-https://github.com/syncfusion-content/wpf-docs/tree/master/wpf/Spreadsheet#
<li>
SfSpreadsheet
<ul>
<li><a href="document-processing/excel/wpf/Spreadsheet/overview">Overview</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/getting-started">Getting Started</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/working-with-sfspreadsheet">Working With Spreadsheet</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/selection">Selection</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/editing">Editing</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/formatting">Formatting</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/conditional-formatting">Conditional Formatting</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/Themes">Themes</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/Sorting-and-Filtering">Sorting and Filtering</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/formulas">Formulas</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/rows-and-columns">Rows and Columns</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/worksheet-management">Worksheet Management</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/data-management">Data Management</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/interactive-features">Interactive Features</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/find-and-replace">Find and Replace</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/outline">Outline</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/shapes">Shapes</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/conversion">Conversion</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/localization">Localization</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/printing">Printing</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/ribbon-customization">Ribbon Customization</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/custom-formula">Custom Formula</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/cell-customization">Cell Customization</a></li>
<li><a href="document-processing/excel/wpf/Spreadsheet/Limitations">Limitations</a></li>
</ul>
</li>
</ul>
</li>
</ul>
Expand Down
162 changes: 162 additions & 0 deletions Document-Processing/Excel/Spreadsheet/Conditional-Formatting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
---
layout: post
title: Conditional Formatting in UWP Spreadsheet control | Syncfusion®
description: Learn here all about Conditional Formatting support in Syncfusion® UWP Spreadsheet (SfSpreadsheet) control and more.
platform: UWP
control: SfSpreadsheet
documentation: ug
---

# Conditional Formatting in UWP Spreadsheet (SfSpreadsheet)

This section explains about how to apply conditional formatting rules programmatically at run time in SfSpreadsheet.

In SfSpreadsheet, to apply conditional format for a cell or range of cells, add `IConditionalFormat` to that range by using `AddCondition` method.

{% tabs %}
{% highlight c# %}
var worksheet =spreadsheet.Workbook.Worksheets[0];
IConditionalFormats condition = worksheet.Range["A1"].ConditionalFormats;
IConditionalFormat condition1 = condition.AddCondition();
{% endhighlight %}
{% endtabs %}

## Highlight Cell Rules

### Based on CellValue

To format the cells based on cell value, define the conditional format type as **CellValue** and other formatting options such as formula, operator, background color etc., to the specified cell or range. Finally, invalidate the cells to refresh the view.

{% tabs %}
{% highlight c# %}
var worksheet = spreadsheet.Workbook.Worksheets[0];
IConditionalFormats condition = worksheet.Range["A1:A100"].ConditionalFormats;
IConditionalFormat condition1 = condition.AddCondition();

condition1.FormatType = ExcelCFType.CellValue;
condition1.Operator = ExcelComparisonOperator.Greater;
condition1.FirstFormula = "10";
condition1.BackColor = ExcelKnownColors.Light_orange;
spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(1));
{% endhighlight %}
{% endtabs %}

### Based on Formula or Cell References

To format the cells based on Formula or Cell References, define the conditional format type as **Formula** and other formatting options such as formula, background color etc., to the specified cell or range. Finally, invalidate the cells to refresh the view.

{% tabs %}
{% highlight c# %}
var worksheet = spreadsheet.Workbook.Worksheets[0];
IConditionalFormats condition = worksheet.Range["A1:A100"].ConditionalFormats;
IConditionalFormat condition1 = condition.AddCondition();

condition1.FormatType = ExcelCFType.Formula;
condition1.FirstFormula = "=(B1+B2)>50";
condition1.BackColor = ExcelKnownColors.Brown;
spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(1));
{% endhighlight %}
{% endtabs %}

### Based on SpecificText

To format the cells based on specified text, define the conditional format type as **SpecificText** and other formatting options such as the particular text, operator, background color etc., to the specified cell or range. Finally, invalidate the cells to refresh the view.

{% tabs %}
{% highlight c# %}
var worksheet = spreadsheet.Workbook.Worksheets[0];
IConditionalFormats condition = worksheet.Range["A1:A100"].ConditionalFormats;
IConditionalFormat condition1 = condition.AddCondition();

condition1.FormatType = ExcelCFType.SpecificText;
condition1.Text = "SYNC";
condition1.Operator = ExcelComparisonOperator.ContainsText;
condition1.BackColor = ExcelKnownColors.Light_orange;
spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(1));
{% endhighlight %}
{% endtabs %}

### Based on TimePeriod

To format the cells based on time period, define the conditional format type as **TimePeriod** and other formatting options such as the time periods for the date, operator, background color etc., to the specified cell or range. Finally, invalidate the cells to refresh the view.

{% tabs %}
{% highlight c# %}
var worksheet = spreadsheet.Workbook.Worksheets[0];
IConditionalFormats condition = worksheet.Range["A1:A100"].ConditionalFormats;
IConditionalFormat condition1 = condition.AddCondition();

condition1.FormatType = ExcelCFType.TimePeriod;
condition1.TimePeriodType = CFTimePeriods.Today
condition1.BackColor = ExcelKnownColors.Light_orange;
spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(1));
{% endhighlight %}
{% endtabs %}

Sample Output

![UWP SfSpreadsheet displays different colors applied as per the conditions ](Conditional-Formatting_images/Conditional-Formatting_img1.PNG)

## Data Bars

To apply the conditional format based on data bars,define the conditional format type as a **DataBar** and specify the properties associated with DataBars such as bar color, MinPoint, MaxPoint etc.,.to the specified cell or range. Finally, invalidate that cells to update the view.

{% tabs %}
{% highlight c# %}
var worksheet = spreadsheet.Workbook.Worksheets[0];
var conditionalFormats = worksheet.Range["B1:B100"].ConditionalFormats;
var conditionalFormat = conditionalFormats.AddCondition();

conditionalFormat.FormatType = ExcelCFType.DataBar;
conditionalFormat.DataBar.BarColor = Color.FromArgb(255, 214, 0, 123);
conditionalFormat.DataBar.MinPoint.Type = ConditionValueType.LowestValue;
conditionalFormat.DataBar.MaxPoint.Type = ConditionValueType.HighestValue;
spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(2));
{% endhighlight %}
{% endtabs %}

Sample Output

![UWP SfSpreadsheet displays different colors applied in different columns based on conditions](Conditional-Formatting_images/Conditional-Formatting_img2.PNG)

## Color Scales

To apply the conditional format based on color scales, define the conditional format type as a **ColorScale** and specify the other properties associated with ColorScale such as condition count,color criteria etc.,to the specified cell or range. Finally,invalidate that cells to update the view.

{% tabs %}
{% highlight c# %}
var worksheet = spreadsheet.Workbook.Worksheets[0];
var conditionalFormats = worksheet.Range["C2:C100"].ConditionalFormats;
var conditionalFormat = conditionalFormats.AddCondition();

conditionalFormat.FormatType = ExcelCFType.ColorScale;
conditionalFormat.ColorScale.SetConditionCount(2);
conditionalFormat.ColorScale.Criteria[0].FormatColorRGB = Color.FromArgb(255, 99, 190, 123);
conditionalFormat.ColorScale.Criteria[1].FormatColorRGB = Color.FromArgb(255, 90, 138, 198);
spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(3));
{% endhighlight %}
{% endtabs %}

Sample Output

![UWP SfSpreadsheet displays colors changed as per the scales](Conditional-Formatting_images/Conditional-Formatting_img3.PNG)

## Icon Sets

To apply the conditional format for Icon sets, define the conditional format type as **IconSet** and the properties associated with IconSet such as the type of the icon,criteria etc., to the specified cell or range. Finally, invalidate that cells to update the view.

{% tabs %}
{% highlight c# %}
var worksheet = spreadsheet.Workbook.Worksheets[0];
var conditionalFormats = worksheet.Range["D2:D100"].ConditionalFormats;
var conditionalFormat = conditionalFormats.AddCondition();

conditionalFormat.FormatType = ExcelCFType.IconSet;
conditionalFormat.IconSet.IconSet = ExcelIconSetType.ThreeSymbols;
spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(4));
{% endhighlight %}
{% endtabs %}

Sample Output

![UWP SfSpreadsheet displays the applied icons as per the applied conditions](Conditional-Formatting_images/Conditional-Formatting_img4.PNG)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions Document-Processing/Excel/Spreadsheet/Custom-Formula.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
layout: post
title: Custom Formula in UWP Spreadsheet control | Syncfusion®
description: Learn here all about Custom Formula support in Syncfusion® UWP Spreadsheet (SfSpreadsheet) control and more.
platform: UWP
control: SfSpreadsheet
documentation: ug
---

# Custom Formula in UWP Spreadsheet (SfSpreadsheet)

SfSpreadsheet allows you to add custom formulas into its function library. You can add the custom formula into the SfSpreadsheet by using the `AddFunction` method of `FormulaEngine`,

{% tabs %}
{% highlight c# %}

spreadsheet.WorkbookLoaded += spreadsheet_WorkbookLoaded;

void spreadsheet_WorkbookLoaded(object sender, WorkbookLoadedEventArgs args)
{

foreach (var grid in args.GridCollection)
AddCustomFormula(grid);

//Computing the formula at runtime
var range = spreadsheetControl.ActiveSheet.Range["B2"];
spreadsheetControl.ActiveGrid.SetCellValue(range,"=FindLength(Sample)");
}

private void AddCustomFormula(SpreadsheetGrid grid)
{

// Add a formula named FindLength to the Library.
grid.FormulaEngine.AddFunction("FindLength", new FormulaEngine.LibraryFunction(ComputeLength));
}

//Implementation of formula

public string ComputeLength(string range)
{

//Used to calculate the length of the string
return range.Length.ToString();
}

{% endhighlight %}
{% endtabs %}
Loading