Skip to content
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
5 changes: 5 additions & 0 deletions Document-Processing-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -5680,6 +5680,11 @@
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/how-to/create-a-object-structure">Create a JSON structure</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/how-to/change-active-sheet">Changing the active sheet while importing a file</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/how-to/identify-the-context-menu-opened">Identify the context menu opened</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/how-to/find-replace-in-range">Find and replace the text within the selected range of cells</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/how-to/add-dynamic-cell-template">Add dynamic cell templates</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/how-to/add-cell-icon">Add an icon to the cell</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/how-to/get-filtered-data">Get the filtered row data</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/how-to/paste-values-without-formatting">paste values without formatting and styles</a></li>
</ul>
</li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/mobile-responsiveness">Mobile Responsiveness</a></li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
layout: post
title: Add icons in cells in EJ2 TypeScript Spreadsheet component | Syncfusion
description: Learn here all about adding icon inside cells using a custom template in Syncfusion EJ2 TypeScript Spreadsheet component of Syncfusion Essential JS 2 and more.
control: Spreadsheet
platform: document-processing
documentation: ug
---

# Add Custom Icons to Cells in EJ2 TypeScript Spreadsheet

In the Syncfusion Spreadsheet, you can render custom icons inside specific cells by defining a custom template property within the cell model. During the [beforeCellRender](https://ej2.syncfusion.com/documentation/api/spreadsheet/index-default#beforecellrender) event, the icon element can be appended to the corresponding table cell (td) by checking whether the cell contains this template property.

The following sample demonstrates how to add icons to cells by assigning the template property in the cell definition. Additionally, a custom ribbon item named "Add Icon" is included under a new "Template" ribbon tab. When this ribbon item is selected, the Spreadsheet dynamically inserts an icon into the currently active cell.

{% tabs %}
{% highlight js tabtitle="index.js" %}
{% include code-snippet/spreadsheet/javascript-es6/add-icon-in-cell-cs1/index.js %}
{% endhighlight %}
{% highlight ts tabtitle="index.html" %}
{% include code-snippet/spreadsheet/javascript-es6/add-icon-in-cell-cs1/index.html %}
{% endhighlight %}
{% endtabs %}

{% previewsample "/document-processing/code-snippet/spreadsheet/javascript-es6/add-icon-in-cell-cs1" %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
layout: post
title: Add cell template in EJ2 TypeScript Spreadsheet component | Syncfusion
description: Render dropdown templates inside cells in Syncfusion EJ2 TypeScript Spreadsheet component of Syncfusion Essential JS 2 and more.
control: Spreadsheet
platform: document-processing
documentation: ug
---

# Create Dynamic Cell Templates in EJ2 TypeScript Spreadsheet

You can add templates to cells in the Syncfusion Spreadsheet component by dynamically assigning a custom template property directly to individual cells. When a cell has this custom template property, you can use the [beforeCellRender](https://ej2.syncfusion.com/documentation/api/spreadsheet/index-default#beforecellrender) event to append the desired template element to the cell.

The following sample demonstrates how to insert a [Syncfusion Dropdown component](https://www.npmjs.com/package/@syncfusion/ej2-dropdowns) into Spreadsheet cells using this custom template property. Additionally, a custom ribbon item named "DropDown List" is included under a new "Template" ribbon tab. When this ribbon item is selected, the Spreadsheet dynamically inserts a dropdown into the currently active cell.

{% tabs %}
{% highlight js tabtitle="index.js" %}
{% include code-snippet/spreadsheet/javascript-es6/dynamic-cell-template-cs1/index.js %}
{% endhighlight %}
{% highlight ts tabtitle="index.html" %}
{% include code-snippet/spreadsheet/javascript-es6/dynamic-cell-template-cs1/index.html %}
{% endhighlight %}
{% endtabs %}

{% previewsample "/document-processing/code-snippet/spreadsheet/javascript-es6/dynamic-cell-template-cs1" %}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ documentation: ug

# Changing the active sheet in EJ2 TypeScript Spreadsheet control

You can change the active sheet of imported file by updating [`activeSheetIndex`](https://helpej2.syncfusion.com/documentation/api/spreadsheet/#activesheetindex) property on the [`openComplete`](https://helpej2.syncfusion.com/documentation/api/spreadsheet/#opencomplete) event.
You can change the active sheet of imported file by updating [`activeSheetIndex`](https://ej2.syncfusion.com/documentation/api/spreadsheet/index-default#activesheetindex) property on the [`openComplete`](https://ej2.syncfusion.com/documentation/api/spreadsheet/index-default#opencomplete) event.

The following code example shows how to set the active sheet when importing an Excel file.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
layout: post
title: Find and replace in EJ2 TypeScript Spreadsheet component | Syncfusion
description: Learn here all about performing find and replace limited to the range in Syncfusion EJ2 TypeScript Spreadsheet component of Syncfusion Essential JS 2 and more.
control: Spreadsheet
platform: document-processing
documentation: ug
---

# Find and replace the text within the selected range of cells

In Syncfusion Spreadsheet, the "Replace All" action by default searches and replaces a text throughout the entire sheet, regardless of the selected range. To limit "Replace All" to only the selected range, you can customize the addressCollection based on the selectedRange in the [actionBegin](https://ej2.syncfusion.com/documentation/api/spreadsheet/index-default#actionbegin) event when the action is `beforeReplaceAll`.

The following sample demonstrates how to limit the "Replace All" operation to the currently selected range.

{% tabs %}
{% highlight js tabtitle="index.js" %}
{% include code-snippet/spreadsheet/javascript-es6/find-and-replace-cs1/index.js %}
{% endhighlight %}
{% highlight ts tabtitle="index.html" %}
{% include code-snippet/spreadsheet/javascript-es6/find-and-replace-cs1/index.html %}
{% endhighlight %}
{% endtabs %}

{% previewsample "/document-processing/code-snippet/spreadsheet/javascript-es6/find-and-replace-cs1" %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
layout: post
title: Filtered row data in EJ2 TypeScript Spreadsheet component | Syncfusion
description: Learn here all about getting filtered row data in Syncfusion EJ2 TypeScript Spreadsheet component of Syncfusion Essential JS 2 and more.
control: Spreadsheet
platform: document-processing
documentation: ug
---

# Get filtered row data in EJ2 TypeScript Spreadsheet

Filtering in the Syncfusion Spreadsheet allows you to display only the rows that match your criteria, hiding all others. You can enable filtering by setting the [allowFiltering](https://ej2.syncfusion.com/documentation/api/spreadsheet/index-default#allowfiltering) property, and apply filters either through the UI or programmatically using the [applyFilter](https://ej2.syncfusion.com/documentation/api/spreadsheet/index-default#applyfilter) method. To identify which rows are filtered, iterate through the sheet's row collection and check the `isFiltered` property of each row object. This flag indicates whether a row is currently hidden due to filtering.

The following example shows how to get the filtered rows from the Spreadsheet:

{% tabs %}
{% highlight js tabtitle="index.js" %}
{% include code-snippet/spreadsheet/javascript-es6/filter-cs2/index.js %}
{% endhighlight %}
{% highlight ts tabtitle="index.html" %}
{% include code-snippet/spreadsheet/javascript-es6/filter-cs2/index.html %}
{% endhighlight %}
{% endtabs %}

{% previewsample "/document-processing/code-snippet/spreadsheet/javascript-es6/filter-cs2" %}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ documentation: ug

The Spreadsheet includes several context menus that will open and display depending on the action. When you right-click on a cell, for example, a context menu with options related to the cell element appears.

The class name returned by the [contextMenuBeforeOpen](https://ej2.syncfusion.com/documentation/api/spreadsheet/#contextmenubeforeopen) event can be used to identify the context menu that is opened. The context menus and their class names are tabulated below.
The class name returned by the [contextMenuBeforeOpen](https://ej2.syncfusion.com/documentation/api/spreadsheet/index-default#contextmenubeforeopen) event can be used to identify the context menu that is opened. The context menus and their class names are tabulated below.

| Class name | Context menu name |
|-------|---------|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
layout: post
title: Paste only values in EJ2 TypeScript Spreadsheet component | Syncfusion
description: Learn here about Paste only values without formatting in Syncfusion EJ2 TypeScript Spreadsheet component of Syncfusion Essential JS 2 and more.
control: Spreadsheet
platform: document-processing
documentation: ug
---

# Paste Values Without Formatting in EJ2 TypeScript Spreadsheet

In the Syncfusion EJ2 TypeScript Spreadsheet, you can make the paste action insert only the raw values into the cells, without bringing any formatting or styles from the copied content. This can be done by using the [actionBegin](https://ej2.syncfusion.com/documentation/api/spreadsheet/index-default#actionbegin) event, where the Spreadsheet provides the details of the action being performed. When the action is a clipboard operation, you can set the paste type to Values, ensuring that only plain values are pasted into the sheet.

The following example shows how to paste values without formatting.

{% tabs %}
{% highlight js tabtitle="index.js" %}
{% include code-snippet/spreadsheet/javascript-es6/paste-values-cs1/index.js %}
{% endhighlight %}
{% highlight ts tabtitle="index.html" %}
{% include code-snippet/spreadsheet/javascript-es6/paste-values-cs1/index.html %}
{% endhighlight %}
{% endtabs %}

{% previewsample "/document-processing/code-snippet/spreadsheet/javascript-es6/paste-values-cs1" %}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ documentation: ug

# Find and replace the text within the selected range of cells

In Syncfusion Spreadsheet, the "Replace All" action by default searches and replaces a text throughout the entire sheet, regardless of the selected range. To limit "Replace All" to only the selected range, you can customize the addressCollection based on the selectedRange in the [actionBegin](https://ej2.syncfusion.com/documentation/api/spreadsheet/index-default#actionbegin) event when the action is `beforeReplaceAll`.
In Syncfusion Spreadsheet, the "Replace All" action by default searches and replaces a text throughout the entire sheet, regardless of the selected range. To limit "Replace All" to only the selected range, you can customize the addressCollection based on the selectedRange in the [actionBegin](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#actionbegin) event when the action is `beforeReplaceAll`.

The following sample demonstrates how to limit the "Replace All" operation to the currently selected range.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title>EJ2 SpreadSheet</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link rel="shortcut icon" href="resources/favicon.ico" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/23.1.36/ej2-base/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/23.1.36/ej2-inputs/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/23.1.36/ej2-buttons/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/23.1.36/ej2-splitbuttons/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/23.1.36/ej2-lists/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/23.1.36/ej2-navigations/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/23.1.36/ej2-popups/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/23.1.36/ej2-dropdowns/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/23.1.36/ej2-grids/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/23.1.36/ej2-spreadsheet/styles/material.css" rel="stylesheet" />
<link href="styles.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/shim.min.js"></script>
<script src="system.config.js"></script>
</head>

<body>
<!--Element which is going to render-->
<div id='loader'>Loading....</div>
<div id='container'>
<div id="spreadsheet"></div>
</div>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Spreadsheet } from '@syncfusion/ej2-spreadsheet';

// To create plus icon wrapper.
function createPlusIconWrapper() {
const wrapperDiv = document.createElement("div");
wrapperDiv.className = 'e-custom-wrapper';
const iconSpan = document.createElement("span");
iconSpan.className = 'e-icons e-plus e-custom-icon';
wrapperDiv.appendChild(iconSpan);
return wrapperDiv;
}

function handleCreated() {
if (!spreadsheet) return;
spreadsheet.updateCell({ template: 'plus-icon' }, 'A1');
spreadsheet.updateCell({ template: 'plus-icon' }, 'B1');
spreadsheet.updateCell({ template: 'plus-icon' }, 'C1');
spreadsheet.resize();
spreadsheet.addRibbonTabs([
{
header: { text: 'Template' },
content: [
{
text: 'Add Icon',
tooltipText: 'Initialize',
click: function () {
if (!spreadsheet) return;
var sheet = spreadsheet.getActiveSheet();
spreadsheet.updateCell(
{ template: 'plus-icon' },
sheet.activeCell
);
spreadsheet.resize();
},
},
],
},
]);
}

function handleBeforeCellRender(args) {
if (args.cell && args.cell.template === 'plus-icon') {
const wrapperDiv = createPlusIconWrapper();
args.element.insertBefore(wrapperDiv, args.element.firstChild);
}
}

let spreadsheet = new Spreadsheet({
created: handleCreated,
beforeCellRender: handleBeforeCellRender,
});

// Render the initialized Spreadsheet
spreadsheet.appendTo('#spreadsheet');
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Spreadsheet } from '@syncfusion/ej2-spreadsheet';

let spreadsheet: Spreadsheet | null = null;

// To create plus icon wrapper.
function createPlusIconWrapper(): HTMLElement {
const wrapperDiv: HTMLDivElement = document.createElement("div");
wrapperDiv.className = 'e-custom-wrapper';
const iconSpan: HTMLSpanElement = document.createElement("span");
iconSpan.className = 'e-icons e-plus e-custom-icon';
wrapperDiv.appendChild(iconSpan);
return wrapperDiv;
}

function handleCreated(): void {
if (!spreadsheet) return;
spreadsheet.updateCell({ template: 'plus-icon' } as any, 'A1');
spreadsheet.updateCell({ template: 'plus-icon' } as any, 'B1');
spreadsheet.updateCell({ template: 'plus-icon' } as any, 'C1');
spreadsheet.resize();
spreadsheet.addRibbonTabs([
{
header: { text: 'Template' },
content: [
{
text: 'Add Icon',
tooltipText: 'Initialize',
click: () => {
if (!spreadsheet) return;
const sheet: any = spreadsheet.getActiveSheet();
spreadsheet.updateCell(
{ template: 'plus-icon' } as any,
sheet.activeCell
);
spreadsheet.resize();
},
},
],
},
]);
}

function handleBeforeCellRender(args: any): void {
if (args.cell && args.cell.template === 'plus-icon') {
const wrapperDiv: HTMLElement = createPlusIconWrapper();
args.element.insertBefore(wrapperDiv, args.element.firstChild);
}
}

spreadsheet = new Spreadsheet({
created: handleCreated,
beforeCellRender: handleBeforeCellRender,
});

// Render the initialized Spreadsheet
spreadsheet.appendTo('#spreadsheet');
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#container {
visibility: hidden;
}

#loader {
color: #008cff;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}
body {
height: 425px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
System.config({
transpiler: "typescript",
typescriptOptions: {
compilerOptions: {
target: "umd",
module: "commonjs",
moduleResolution: "node",
emitDecoratorMetadata: true,
experimentalDecorators: true
}
},
paths: {
"syncfusion:": "https://cdn.syncfusion.com/ej2/23.1.36/"
},
map: {
main: "index.ts",
typescript: "https://unpkg.com/typescript@2.2.2/lib/typescript.js",
//Syncfusion packages mapping
"@syncfusion/ej2-base": "syncfusion:ej2-base/dist/ej2-base.umd.min.js",
"@syncfusion/ej2-data": "syncfusion:ej2-data/dist/ej2-data.umd.min.js",
"@syncfusion/ej2-inputs": "syncfusion:ej2-inputs/dist/ej2-inputs.umd.min.js",
"@syncfusion/ej2-buttons": "syncfusion:ej2-buttons/dist/ej2-buttons.umd.min.js",
"@syncfusion/ej2-splitbuttons": "syncfusion:ej2-splitbuttons/dist/ej2-splitbuttons.umd.min.js",
"@syncfusion/ej2-lists": "syncfusion:ej2-lists/dist/ej2-lists.umd.min.js",
"@syncfusion/ej2-navigations": "syncfusion:ej2-navigations/dist/ej2-navigations.umd.min.js",
"@syncfusion/ej2-notifications": "syncfusion:ej2-notifications/dist/ej2-notifications.umd.min.js",
"@syncfusion/ej2-popups": "syncfusion:ej2-popups/dist/ej2-popups.umd.min.js",
"@syncfusion/ej2-dropdowns": "syncfusion:ej2-dropdowns/dist/ej2-dropdowns.umd.min.js",
"@syncfusion/ej2-calendars": "syncfusion:ej2-calendars/dist/ej2-calendars.umd.min.js",
"@syncfusion/ej2-excel-export": "syncfusion:ej2-excel-export/dist/ej2-excel-export.umd.min.js",
"@syncfusion/ej2-pdf-export": "syncfusion:ej2-pdf-export/dist/ej2-pdf-export.umd.min.js",
"@syncfusion/ej2-file-utils": "syncfusion:ej2-file-utils/dist/ej2-file-utils.umd.min.js",
"@syncfusion/ej2-compression": "syncfusion:ej2-compression/dist/ej2-compression.umd.min.js",
"@syncfusion/ej2-grids": "syncfusion:ej2-grids/dist/ej2-grids.umd.min.js",
"@syncfusion/ej2-charts": "syncfusion:ej2-charts/dist/ej2-charts.umd.min.js",
"@syncfusion/ej2-svg-base": "syncfusion:ej2-svg-base/dist/ej2-svg-base.umd.min.js",
"@syncfusion/ej2-spreadsheet": "syncfusion:ej2-spreadsheet/dist/ej2-spreadsheet.umd.min.js"
}
});

System.import('index.ts').catch(console.error.bind(console)).then(function () {
document.getElementById('loader').style.display = "none";
document.getElementById('container').style.visibility = "visible";
});
Loading