Grocery Store

A grocery store data grid example with search, pagination and file upload.

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

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

<script>
let data = [
    [ 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Vegetable-Carrot-Bundle-wStalks.jpg/220px-Vegetable-Carrot-Bundle-wStalks.jpg', 'Vegetables', 'Carrots', '2019-02-12', '14.00', '4' ],
    [ 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Pink_lady_and_cross_section.jpg/1920px-Pink_lady_and_cross_section.jpg', 'Fruits', 'Apple', '2019-03-01', '45.00', '5'],
    [ 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/32/Split_ananas.jpg/800px-Split_ananas.jpg', 'Fruits', 'Pineapples', '2018-11-10', '30.00', '4'],
    [ 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Plums_African_Rose_-_whole%2C_halved_and_slice.jpg/1280px-Plums_African_Rose_-_whole%2C_halved_and_slice.jpg', 'Fruits', 'Plums', '2019-01-12', '14.00', '4' ],
];

jspreadsheet(document.getElementById('spreadsheet'), {
    worksheets: [{
        data: data,
        search: true,
        pagination: 10,
        paginationOptions: [10,25,50],
        columns: [
            { type: 'image', width: '110px', title: 'Photo' },
            {
                type: 'dropdown',
                width: '120px',
                title: 'Category',
                source: [
                    'Vegetables',
                    'Fruits',
                    'Grains, Beans and Nuts',
                    'Meat and Poultry',
                    'Fish and Seafood',
                    'Dairy Foods'
                ]
            },
            { type: 'text', width: '150px', title: 'Description' },
            { type: 'calendar', width: '100px', title: 'Best before' },
            { type: 'text', width: '80px', title: 'Price', mask: '$ #,##0.00' },
            { type: 'rating', width: '90px', title: 'Rating', color: 'red' }
         ],
    }]
});
</script>
</html>
import React, { useRef } from "react";
import { Spreadsheet, Worksheet } from "@jspreadsheet/react";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";

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

// Create the component
export default function App() {
    // Spreadsheet array of worksheets
    const spreadsheet = useRef();
    // Data
    const data = [
        [ 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Vegetable-Carrot-Bundle-wStalks.jpg/220px-Vegetable-Carrot-Bundle-wStalks.jpg', 'Vegetables', 'Carrots', '2019-02-12', '14.00', '4' ],
        [ 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Pink_lady_and_cross_section.jpg/1920px-Pink_lady_and_cross_section.jpg', 'Fruits', 'Apple', '2019-03-01', '45.00', '5'],
        [ 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/32/Split_ananas.jpg/800px-Split_ananas.jpg', 'Fruits', 'Pineapples', '2018-11-10', '30.00', '4'],
        [ 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Plums_African_Rose_-_whole%2C_halved_and_slice.jpg/1280px-Plums_African_Rose_-_whole%2C_halved_and_slice.jpg', 'Fruits', 'Plums', '2019-01-12', '14.00', '4' ],
    ];
    // Columns
    const columns = [
        { type: 'image', width: '110px', title: 'Photo' },
        {
            type: 'dropdown',
            width: '120px',
            title: 'Category',
            source: [
                'Vegetables',
                'Fruits',
                'Grains, Beans and Nuts',
                'Meat and Poultry',
                'Fish and Seafood',
                'Dairy Foods'
            ]
        },
        { type: 'text', width: '150px', title: 'Description' },
        { type: 'calendar', width: '100px', title: 'Best before' },
        { type: 'text', width: '80px', title: 'Price', mask: '$ #,##0.00' },
        { type: 'rating', width: '90px', title: 'Rating', color: 'red' }
    ];

    // Render data grid component
    return (
        <Spreadsheet ref={spreadsheet} license={license}>
            <Worksheet data={data} columns={columns} search pagination={"10"} paginationOptions={[10,25,50]} />
        </Spreadsheet>
    );
}
<template>
    <Spreadsheet ref="spreadsheet">
        <Worksheet :data="data" :columns="columns" :search="true" pagination="10" :paginationOptions="[10,25,50]" />
    </Spreadsheet>
</template>

<script>
import { Spreadsheet, Worksheet } from "@jspreadsheet/vue";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";

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

const data = [
    [ 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Vegetable-Carrot-Bundle-wStalks.jpg/220px-Vegetable-Carrot-Bundle-wStalks.jpg', 'Vegetables', 'Carrots', '2019-02-12', '14.00', '4' ],
    [ 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Pink_lady_and_cross_section.jpg/1920px-Pink_lady_and_cross_section.jpg', 'Fruits', 'Apple', '2019-03-01', '45.00', '5'],
    [ 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/32/Split_ananas.jpg/800px-Split_ananas.jpg', 'Fruits', 'Pineapples', '2018-11-10', '30.00', '4'],
    [ 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Plums_African_Rose_-_whole%2C_halved_and_slice.jpg/1280px-Plums_African_Rose_-_whole%2C_halved_and_slice.jpg', 'Fruits', 'Plums', '2019-01-12', '14.00', '4' ],
];

// Create components
export default {
    components: {
        Spreadsheet,
        Worksheet,
    },
    data() {
        // Data
        const data = [
            [ 'Test', '=QTY*MAX', '=HELLO' ],
        ];
        // Columns
        const columns = [
            { type: 'image', width: '110px', title: 'Photo' },
            {
                type: 'dropdown',
                width: '120px',
                title: 'Category',
                source: [
                    'Vegetables',
                    'Fruits',
                    'Grains, Beans and Nuts',
                    'Meat and Poultry',
                    'Fish and Seafood',
                    'Dairy Foods'
                ]
            },
            { type: 'text', width: '150px', title: 'Description' },
            { type: 'calendar', width: '100px', title: 'Best before' },
            { type: 'text', width: '80px', title: 'Price', mask: '$ #,##0.00' },
            { type: 'rating', width: '90px', title: 'Rating', color: 'red' }
        ];

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

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

// Set the license
jspreadsheet.setLicense('MjRiOTUzMzNhNGMxY2IwNzY0N2RlNTUxMzM1YmZmNWFlMGJhOTk1NDg3M2RjODI0MjVjMmQ4MGExNjBlODBlYjQ3ZTE1ZjVkNzhkYWMzMmZlM2JjYzZiOGFhZmNkZmRkMWIwMGExMjg1ZGJmZmNlY2NhMDg3ZjQ0YTM4OTkyZmQsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpNeU1qWTBPVGN3TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==');

const data = [
    ['https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Vegetable-Carrot-Bundle-wStalks.jpg/220px-Vegetable-Carrot-Bundle-wStalks.jpg', 'Vegetables', 'Carrots', '2019-02-12', '14.00', '4'],
    ['https://upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Pink_lady_and_cross_section.jpg/1920px-Pink_lady_and_cross_section.jpg', 'Fruits', 'Apple', '2019-03-01', '45.00', '5'],
    ['https://upload.wikimedia.org/wikipedia/commons/thumb/3/32/Split_ananas.jpg/800px-Split_ananas.jpg', 'Fruits', 'Pineapples', '2018-11-10', '30.00', '4'],
    ['https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Plums_African_Rose_-_whole%2C_halved_and_slice.jpg/1280px-Plums_African_Rose_-_whole%2C_halved_and_slice.jpg', 'Fruits', 'Plums', '2019-01-12', '14.00', '4'],
];

// Create the data grid component
@Component({
    standalone: true,
    selector: "app-root",
    template: `<div #spreadsheet></div>`,
})
export class AppComponent {
    @ViewChild("spreadsheet") spreadsheet: ElementRef;
    // Worksheets
    worksheets: jspreadsheet.worksheetInstance[];
    // Create a new data grid
    ngAfterViewInit() {
        // Create summary spreadsheet
        this.worksheets = jspreadsheet(this.spreadsheet.nativeElement, {
            worksheets: [{
                data: data,
                search: true,
                pagination: 10,
                paginationOptions: [10, 25, 50],
                columns: [
                    { type: 'image', width: '110px', title: 'Photo' },
                    {
                        type: 'dropdown',
                        width: '120px',
                        title: 'Category',
                        source: [
                            'Vegetables',
                            'Fruits',
                            'Grains, Beans and Nuts',
                            'Meat and Poultry',
                            'Fish and Seafood',
                            'Dairy Foods'
                        ]
                    },
                    { type: 'text', width: '150px', title: 'Description' },
                    { type: 'calendar', width: '100px', title: 'Best before' },
                    { type: 'text', width: '80px', title: 'Price', mask: '$ #,##0.00' },
                    { type: 'rating', width: '90px', title: 'Rating', color: 'red' }
                ],
            }]
        });
    }
}