Advanced Data Grid Search and Replace

Advanced Search

Introducing the Advanced Search and Replace extension for JSS spreadsheets and data grids. This powerful extension enhances your data editing experience by incorporating search and replace functionality similar to other spreadsheet software. Seamlessly search for specific data patterns and efficiently replace them throughout your JSS spreadsheets and data grids, empowering you to modify and update your data with ease quickly.

Documentation

Methods

Method Description
search(object?) To open the search modal programmatically, you must specify the target worksheet instance or if no instance is provided, the function will use the currently active worksheet by default. However, an alert will be displayed to notify the user if no spreadsheet is in focus.
search(worksheet?: object) => void

Events

Event Description
onsearch After the search process is completed.
onbeforesearch(worksheet: Object, terms: String, rowNumber: Array, search: Object)

Installation

Please choose one of the following options

Using NPM

$ npm install @jspreadsheet/search

Using a CDN

<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/search/dist/index.min.js"></script>

Examples

Enable the search and replace extension

Click in the search icon in the toolbar to open the search and replace features.

<html>
<script src="https://jspreadsheet.com/v11/jspreadsheet.js"></script>
<link rel="stylesheet" href="https://jspreadsheet.com/v11/jspreadsheet.css" type="text/css" />
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />

<script src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/search/dist/index.min.js"></script>

<div id="spreadsheet"></div>

<p><input type="button" value="Open Search Modal" id="btn1" /></p>

<script>
// Set the license for both plugin and the spreadsheet
jspreadsheet.setLicense('Yjk2MTJlZDhjZDUyMDg4NTljOTBhZjViNTM0OWEwNjVjNjgzYzQ4ZTIzNzYzOWE4MGYzOWIzNjM0ZjllZDJhNjlmZmU0NmViMGY4Y2IxZGI4M2RhMDM2ZDAxY2JlMWE5NDA5ZmIzZjg1ZGRjMDQxYmYxNThmMmNhZGQ4N2U3MmUsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpFNE9UVTNOems1TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==');

// Set the extensions
jspreadsheet.setExtensions({ search });

// Create the spreadsheet
let worksheets = jspreadsheet(document.getElementById('spreadsheet'), {
    worksheets: [{
        csv: '/tests/demo.csv',
        tableOverflow: true,
        tableWidth: '700px',
        tableHeight: '400px',
        columns: [
            { width: '80px' },
            { width: '200px' },
            { width: '100px' },
            { width: '200px' },
            { width: '100px' }
        ]
    }],
});

document.getElementById("btn1").onclick = () => search(worksheets[0])
</script>
</html>
import React, { useRef } from "react";
import { Spreadsheet, Worksheet } from "@jspreadsheet/react";
import search from "@jspreadsheet/search";

import "@jsuites/css/dist/style.css"
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";

// Set the license
const license = 'Yjk2MTJlZDhjZDUyMDg4NTljOTBhZjViNTM0OWEwNjVjNjgzYzQ4ZTIzNzYzOWE4MGYzOWIzNjM0ZjllZDJhNjlmZmU0NmViMGY4Y2IxZGI4M2RhMDM2ZDAxY2JlMWE5NDA5ZmIzZjg1ZGRjMDQxYmYxNThmMmNhZGQ4N2U3MmUsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpFNE9UVTNOems1TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==';

// Define the extensions
const extensions = { search };

export default function App() {
    // Spreadsheet array of worksheets
    const spreadsheet = useRef();
    // Render component
    return (
        <>
            <Spreadsheet ref={spreadsheet} license={license} extensions={extensions}>
                <Worksheet
                    minDimensions={[5, 5]}
                    csv={"/tests/demo.csv"}
                    tableWidth={"700px"}
                    tableHeight={"400px"}
                    tableOverflow
                />
            </Spreadsheet>
            <input type="button" value="Open search modal"
                onClick={() => search(spreadsheet.current[0])}/>
        </>
    );
}
<template>
    <Spreadsheet ref="spreadsheet" :license="license" :extensions="extensions" :worksheets="worksheets" />
    <input type="button" value="Open search modal" @click="modal" />
</template>

<script>
import { Spreadsheet, Worksheet } from "@jspreadsheet/vue";
import search from "@jspreadsheet/search";

import "@jsuites/css/dist/style.css"
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";

// Set the license
const license = 'Yjk2MTJlZDhjZDUyMDg4NTljOTBhZjViNTM0OWEwNjVjNjgzYzQ4ZTIzNzYzOWE4MGYzOWIzNjM0ZjllZDJhNjlmZmU0NmViMGY4Y2IxZGI4M2RhMDM2ZDAxY2JlMWE5NDA5ZmIzZjg1ZGRjMDQxYmYxNThmMmNhZGQ4N2U3MmUsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpFNE9UVTNOems1TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==';

// Extensions
const extensions = { search };

export default {
    components: {
        Spreadsheet,
        Worksheet,
    },
    methods: {
        modal() {
            search(this.$refs.spreadsheet.current[0]);
        }
    },
    data() {
        const worksheets = [{
            csv: "/tests/demo.csv",
            tableOverflow: true,
            tableWidth: "700px",
            tableHeight: "400px",
        }]

        return {
            worksheets,
            license,
            search,
        };
    }
}
</script>
import { Component, ViewChild, ElementRef } from "@angular/core";
import jspreadsheet from "jspreadsheet";
import search from "@jspreadsheet/search";

import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";

// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('Yjk2MTJlZDhjZDUyMDg4NTljOTBhZjViNTM0OWEwNjVjNjgzYzQ4ZTIzNzYzOWE4MGYzOWIzNjM0ZjllZDJhNjlmZmU0NmViMGY4Y2IxZGI4M2RhMDM2ZDAxY2JlMWE5NDA5ZmIzZjg1ZGRjMDQxYmYxNThmMmNhZGQ4N2U3MmUsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpFNE9UVTNOems1TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==');

// Extensions
jspreadsheet.setExtensions({ search });

@Component({
    standalone: true,
    selector: "app-root",
    template: `<div #spreadsheet></div>
    <input type="button" value="Open search modal" onclick="search(this.worksheets[0])" />`
})
export class AppComponent {
    @ViewChild("spreadsheet") spreadsheet: ElementRef;
    // Worksheets
    worksheets: jspreadsheet.worksheetInstance[];
    // Create a new data grid
    ngAfterViewInit() {
        // Create spreadsheet
        this.worksheets = jspreadsheet(this.spreadsheet.nativeElement, {
            worksheets: [{
                minDimensions: [10, 10],
                csv: "https://jspreadsheet.com/tests/demo.csv",
                tableOverflow: true,
                tableWidth: "700px",
                tableHeight: "400px",
            }]
        });
    }
}