Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ documentation: ug

# Conditional Formatting in Windows Forms Spreadsheet

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

In Spreadsheet, to apply conditional format for a cell or range of cells, add [IConditionalFormat](https://help.syncfusion.com/cr/windowsforms/Syncfusion.XlsIO.IConditionalFormat.html) to that range by using [AddCondition](https://help.syncfusion.com/cr/windowsforms/Syncfusion.XlsIO.IConditionalFormats.html#Syncfusion_XlsIO_IConditionalFormats_AddCondition) method.
In Spreadsheet, to apply a conditional format to a cell or range of cells, add a new [IConditionalFormat](https://help.syncfusion.com/cr/windowsforms/Syncfusion.XlsIO.IConditionalFormat.html) to that range by using the [AddCondition](https://help.syncfusion.com/cr/windowsforms/Syncfusion.XlsIO.IConditionalFormats.html#Syncfusion_XlsIO_IConditionalFormats_AddCondition) method.

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

var worksheet =spreadsheet.Workbook.Worksheets[0];
var worksheet = spreadsheet.Workbook.Worksheets[0];
IConditionalFormats condition = worksheet.Range["A1"].ConditionalFormats;
IConditionalFormat condition1 = condition.AddCondition();

Expand All @@ -25,9 +25,9 @@ IConditionalFormat condition1 = condition.AddCondition();

## Highlight Cell Rules

### Based on CellValue
### Based on Cell Value

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.
To format the cells based on a 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# %}
Expand All @@ -48,7 +48,7 @@ spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(1));

### 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.
To format the cells based on a 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# %}
Expand All @@ -66,9 +66,9 @@ spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(1));
{% endhighlight %}
{% endtabs %}

### Based on SpecificText
### Based on Specific Text

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.
To format the cells based on a 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# %}
Expand All @@ -87,9 +87,9 @@ spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(1));
{% endhighlight %}
{% endtabs %}

### Based on TimePeriod
### Based on Time Period

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.
To format the cells based on a 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# %}
Expand All @@ -98,27 +98,27 @@ 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.TimePeriodType = CFTimePeriods.Today;
condition1.BackColor = ExcelKnownColors.Light_orange;

spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(1));

{% endhighlight %}
{% endtabs %}

Sample Output
**Sample Output**

![Formatting based on time](Conditional-Formatting_images/Conditional-Formatting_img1.PNG)
![Formatting based on time period](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.
To apply the conditional format based on data bars, define the conditional format type as **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 conditionalFormats = worksheet.Range["B1:B100"].ConditionalFormats;
var conditionalFormat = conditionalFormats.AddCondition();

conditionalFormat.FormatType = ExcelCFType.DataBar;
Expand All @@ -131,13 +131,13 @@ spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(2));
{% endhighlight %}
{% endtabs %}

Sample Output
**Sample Output**

![Appearance with data bars](Conditional-Formatting_images/Conditional-Formatting_img2.PNG)
![Formatting with data bars](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.
To apply the conditional format based on color scales, define the conditional format type as **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# %}
Expand All @@ -156,14 +156,13 @@ spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(3));
{% endhighlight %}
{% endtabs %}

Sample Output

![Formatting using color gradient](Conditional-Formatting_images/Conditional-Formatting_img3.PNG)
**Sample Output**

![Formatting using color scale](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.
To apply the conditional format based on 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# %}
Expand All @@ -180,6 +179,6 @@ spreadsheet.ActiveGrid.InvalidateCell(GridRangeInfo.Col(4));
{% endhighlight %}
{% endtabs %}

Sample Output
**Sample Output**

![Formatting with icons](Conditional-Formatting_images/Conditional-Formatting_img4.PNG)
![Formatting with icon sets](Conditional-Formatting_images/Conditional-Formatting_img4.PNG)
25 changes: 12 additions & 13 deletions Document-Processing/Excel/Spreadsheet/Winforms/Conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ documentation: ug
---

# Conversion in Windows Forms Spreadsheet
This section explains about the conversion of workbook in Spreadsheet into image, PDF and HTML
This section explains the conversion of a workbook in Spreadsheet to image, PDF, and HTML formats.

## Convert into Image
## Convert to Image

Spreadsheet provides support to convert a worksheet in to an image of type Bitmap or Metafile based on the input range of rows and columns with all basic formats preserved, By using the [ConvertToImage](https://help.syncfusion.com/cr/windowsforms/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_ConvertToImage_System_Int32_System_Int32_System_Int32_System_Int32_) method,worksheet can be converted into an image.
Spreadsheet provides support to convert a worksheet into an image of type `Bitmap` or `Metafile` based on the input range of rows and columns with all basic formats preserved. By using the [ConvertToImage](https://help.syncfusion.com/cr/windowsforms/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_ConvertToImage_System_Int32_System_Int32_System_Int32_System_Int32_) method, you can convert a worksheet into an image.

{% tabs %}
{% highlight c# %}
{% highlight c# tabtitle="C#" %}

IWorksheet sheet = spreadsheet.Workbook.ActiveSheet;
sheet.UsedRangeIncludesFormatting = false;
Expand All @@ -31,16 +31,16 @@ System.Diagnostics.Process.Start("Sample.png");
{% endhighlight %}
{% endtabs %}

## Convert into PDF
## Convert to PDF

Spreadsheet provides support to export the Excel workbook to PDF using ExcelToPdfConverter.
Spreadsheet provides support to export the Excel workbook to PDF using `ExcelToPdfConverter`.

For converting the Excel sheet to PDF, Syncfusion.ExcelToPDFConverter.Base.dll and Syncfusion.Pdf.Base.dll references should be added.
For converting the Excel worksheet to PDF, the `Syncfusion.ExcelToPDFConverter.Base.dll` and `Syncfusion.Pdf.Base.dll` references should be added.

Export the Excel workbook as PDF document using [Convert](https://help.syncfusion.com/cr/windowsforms/Syncfusion.ExcelToPdfConverter.ExcelToPdfConverter.html#Syncfusion_ExcelToPdfConverter_ExcelToPdfConverter_Convert) method of [ExcelToPdfConverter](https://help.syncfusion.com/cr/windowsforms/Syncfusion.ExcelToPdfConverter.ExcelToPdfConverter.html) class which is available under the name space “Syncfusion.ExcelToPdfConverter
Export the Excel workbook as a PDF document using the [Convert](https://help.syncfusion.com/cr/windowsforms/Syncfusion.ExcelToPdfConverter.ExcelToPdfConverter.html#Syncfusion_ExcelToPdfConverter_ExcelToPdfConverter_Convert) method of the [ExcelToPdfConverter](https://help.syncfusion.com/cr/windowsforms/Syncfusion.ExcelToPdfConverter.ExcelToPdfConverter.html) class, which is available in the namespace `Syncfusion.ExcelToPdfConverter`.

{% tabs %}
{% highlight c# %}
{% highlight c# tabtitle="C#" %}

ExcelToPdfConverter converter = new ExcelToPdfConverter(spreadsheet.Workbook);

Expand All @@ -65,16 +65,15 @@ System.Diagnostics.Process.Start("Sample.pdf");
{% endhighlight %}
{% endtabs %}

## Convert into HTML
## Convert to HTML

Spreadsheet provides support to convert the excel workbook into HTML page.
Spreadsheet provides support to convert the Excel workbook into an HTML page.

{% tabs %}
{% highlight c# %}
{% highlight c# tabtitle="C#" %}

spreadsheet.Workbook.SaveAsHtml("Sample.html", HtmlSaveOptions.Default);
System.Diagnostics.Process.Start("Sample.html");

{% endhighlight %}
{% endtabs %}

15 changes: 8 additions & 7 deletions Document-Processing/Excel/Spreadsheet/Winforms/Custom-Formula.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ documentation: ug

# Custom Formula in Windows Forms Spreadsheet

Spreadsheet allows you to add custom formulas into its function library. You can add the custom formula into the Spreadsheet by using the [AddFunction](https://help.syncfusion.com/cr/windowsforms/Syncfusion.Windows.Forms.CellGrid.FormulaEngine.html#Syncfusion_Windows_Forms_CellGrid_FormulaEngine_AddFunction_System_String_Syncfusion_Windows_Forms_CellGrid_FormulaEngine_LibraryFunction_) method of [FormulaEngine](https://help.syncfusion.com/cr/windowsforms/Syncfusion.Windows.Forms.CellGrid.FormulaEngine.html),
Spreadsheet allows you to add custom formulas into its function library by using the [AddFunction](https://help.syncfusion.com/cr/windowsforms/Syncfusion.Windows.Forms.CellGrid.FormulaEngine.html#Syncfusion_Windows_Forms_CellGrid_FormulaEngine_AddFunction_System_String_Syncfusion_Windows_Forms_CellGrid_FormulaEngine_LibraryFunction_) method of [FormulaEngine](https://help.syncfusion.com/cr/windowsforms/Syncfusion.Windows.Forms.CellGrid.FormulaEngine.html).

{% tabs %}
{% highlight c# %}
Expand All @@ -19,28 +19,29 @@ spreadsheet.WorkbookLoaded += spreadsheet_WorkbookLoaded;
void spreadsheet_WorkbookLoaded(object sender, WorkbookLoadedEventArgs args)
{

// Iterate over every grid in the loaded workbook and register the custom formula on each one.
foreach (var grid in args.GridCollection)
AddCustomFormula(grid);

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

}

private void AddCustomFormula(SpreadsheetGrid grid)
{

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

//Implementation of formula
// Custom formula implementation.

public string ComputeLength(string range)
{

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

Expand Down
20 changes: 9 additions & 11 deletions Document-Processing/Excel/Spreadsheet/Winforms/Data-Management.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ documentation: ug
---

# Data Management in Windows Forms Spreadsheet
This section explains about how to import and export the DataTable in `Spreadsheet`.
This section explains how to import and export data in the Syncfusion® `Spreadsheet` control.

## Import from DataTable

Spreadsheet provides support to import the data. The following list of data can be imported into the worksheet
The following data sources can be imported into the worksheet:

* Data Table
* Data Column
* Data View
* DataTable
* DataColumn
* DataView
* Business Objects
* Array

To import the data from a data table, you can use [ImportDataTable](https://help.syncfusion.com/file-formats/xlsio/working-with-data#importing-data-to-worksheets)
method
To import data from a `DataTable`, use the [ImportDataTable](https://help.syncfusion.com/file-formats/xlsio/working-with-data#importing-data-to-worksheets) method.

{% tabs %}
{% highlight c# %}
Expand All @@ -32,12 +31,11 @@ spreadsheet.ActiveGrid.InvalidateCells();
{% endhighlight %}
{% endtabs %}

For more details regarding importing of data, please refer the [XlsIO UG](https://help.syncfusion.com/file-formats/xlsio/working-with-data#importing-data-to-worksheets)
For more details, refer to the [XlsIO UG](https://help.syncfusion.com/file-formats/xlsio/working-with-data#importing-data-to-worksheets).

## Export to DataTable

Spreadsheet provides support to export the data. To Export the data from a data table, you can use [ExportDataTable](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-data-table)
method
To export worksheet data to a `DataTable`, use the [ExportDataTable](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-data-table) method.

{% tabs %}
{% highlight c# %}
Expand All @@ -50,4 +48,4 @@ DataTable data_table = sheet.ExportDataTable(range, ExcelExportDataTableOptions.
{% endhighlight %}
{% endtabs %}

For more details regarding exporting of data, please refer the [XlsIO UG](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-data-table)
For more details, refer to the [XlsIO UG](https://help.syncfusion.com/file-formats/xlsio/working-with-data#exporting-from-worksheet-to-data-table).
Loading