Data grid performance
This section will discuss what to consider for optimizing the data grid performance when working with large datasets.
What's new
Jspreadsheet version 10 introduces significant improvements and optimizations that enhance the performance and user experience of the application. One of the significant advancements is eliminating duplicate information and using global CSS classes for styling. This approach streamlines the code, making it more efficient and easier to manage. The new version includes a better navigation system that leverages the viewport to load only the data visible to the user. This feature enhances the user experience by creating a seamless and speedy performance while minimizing the application's resource utilization.
Smart viewport
You can activate the smarter viewport by enabling pagination, table overflow, or full-screen properties. Overall, the improvements and optimizations in Jspreadsheet version 10 provide users with a more efficient and smoother experience.
tableOverflow: boolean
It defines the viewport width and height dimensions.
fullscreen: boolean
This property is handy for rendering as many cells as possible to fit the screen.
pagination: number
This property activates the pagination feature, which displays a fixed number of rows and creates a pagination bar..
Examples
A data grid with 5 million cells
The following example will create a table from an array with 100 columns x 50000 rows (five million cells)
|
---|
1 | A1 | B1 | C1 | D1 | E1 | F1 | G1 | H1 | I1 |
2 | A2 | B2 | C2 | D2 | E2 | F2 | G2 | H2 | I2 |
3 | A3 | B3 | C3 | D3 | E3 | F3 | G3 | H3 | I3 |
4 | A4 | B4 | C4 | D4 | E4 | F4 | G4 | H4 | I4 |
5 | A5 | B5 | C5 | D5 | E5 | F5 | G5 | H5 | I5 |
6 | A6 | B6 | C6 | D6 | E6 | F6 | G6 | H6 | I6 |
7 | A7 | B7 | C7 | D7 | E7 | F7 | G7 | H7 | I7 |
8 | A8 | B8 | C8 | D8 | E8 | F8 | G8 | H8 | I8 |
9 | A9 | B9 | C9 | D9 | E9 | F9 | G9 | H9 | I9 |
10 | A10 | B10 | C10 | D10 | E10 | F10 | G10 | H10 | I10 |
11 | A11 | B11 | C11 | D11 | E11 | F11 | G11 | H11 | I11 |
12 | A12 | B12 | C12 | D12 | E12 | F12 | G12 | H12 | I12 |
13 | A13 | B13 | C13 | D13 | E13 | F13 | G13 | H13 | I13 |
14 | A14 | B14 | C14 | D14 | E14 | F14 | G14 | H14 | I14 |
15 | A15 | B15 | C15 | D15 | E15 | F15 | G15 | H15 | I15 |
The table was created in: 563ms
<html>
<script src="https://jspreadsheet.com/v10/jspreadsheet.js"></script>
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jspreadsheet.com/v10/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>
<br/><div id="console"></div>
<script>
jspreadsheet.setLicense('MTg0ZWY0OTljNjBmZmQ1MDM4ZWFkYzkwM2E1Y2U4NDZiY2YxYmU4NDc0MmJkY2ZjNDk3ZjhjOTQ5NzIyZDE3NTZkMzZkMGE2MmUyZDEzODcyNmQxZGE3OTIxYWU2ZGEwZDhjYjRjNjE0Yjk5YTczMjFkMmEzOGE0MTBhYWI5MmUsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpRME1ESXlOek0zTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==');
let data = [];
for (let j = 0; j < 50000; j++) {
data[j] = [];
for (let i = 0; i < 100; i++) {
data[j][i] = jspreadsheet.helpers.getColumnNameFromCoords(i, j);
}
}
let s = Date.now();
jspreadsheet(document.getElementById('spreadsheet'), {
worksheets: [{
data: data,
tableOverflow: true,
tableWidth: '800px',
tableHeight: '300px',
}],
onload: function() {
let e = Date.now();
document.getElementById('console').innerText = 'The table was created in: ' + (e - s) + 'ms';
}
})
</script>
</html>
import React, { useRef } from "react";
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/react";
const license = 'MTg0ZWY0OTljNjBmZmQ1MDM4ZWFkYzkwM2E1Y2U4NDZiY2YxYmU4NDc0MmJkY2ZjNDk3ZjhjOTQ5NzIyZDE3NTZkMzZkMGE2MmUyZDEzODcyNmQxZGE3OTIxYWU2ZGEwZDhjYjRjNjE0Yjk5YTczMjFkMmEzOGE0MTBhYWI5MmUsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpRME1ESXlOek0zTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==';
export default function App() {
const spreadsheet = useRef();
const console = useRef();
const data = [];
for (let j = 0; j < 50000; j++) {
data[j] = [];
for (let i = 0; i < 100; i++) {
data[j][i] = jspreadsheet.helpers.getColumnNameFromCoords(i, j);
}
}
let s = Date.now();
const onload = () => {
let e = Date.now();
console.current.innerText = 'The table was created in: ' + (e - s) + 'ms';
};
return (
<>
<Spreadsheet ref={spreadsheet} license={license} onload={onload}>
<Worksheet data={data} tableOverflow={true} tableWidth="800px" tableHeight="300px" />
</Spreadsheet>
<div ref={console}></div>
</>
);
}
<template>
<Spreadsheet :license="license">
<Worksheet :data="data" tableOverflow tableWidth="800px" tableHeight="300px" />
</Spreadsheet>
<div ref="console"></div>
</template>
<script>
import { ref } from 'vue';
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/vue";
const license = 'MTg0ZWY0OTljNjBmZmQ1MDM4ZWFkYzkwM2E1Y2U4NDZiY2YxYmU4NDc0MmJkY2ZjNDk3ZjhjOTQ5NzIyZDE3NTZkMzZkMGE2MmUyZDEzODcyNmQxZGE3OTIxYWU2ZGEwZDhjYjRjNjE0Yjk5YTczMjFkMmEzOGE0MTBhYWI5MmUsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpRME1ESXlOek0zTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==';
const data = [];
for (let j = 0; j < 1000; j++) {
data[j] = [];
for (let i = 0; i < 100; i++) {
data[j][i] = jspreadsheet.helpers.getColumnNameFromCoords(i, j);
}
}
export default {
components: {
Spreadsheet,
Worksheet
},
setup() {
const log = ref(null);
let s = Date.now();
const onload = () => {
let e = Date.now();
log.value.innerText = 'The table was created in: ' + (e - s) + 'ms';
}
return {
license,
data,
onload,
log,
};
}
}
</script>
import { Component, ViewChild, ElementRef } from "@angular/core";
import jspreadsheet from "jspreadsheet";
import "jspreadsheet/dist/jspreadsheet.css"
import "jsuites/dist/jsuites.css"
jspreadsheet.setLicense('MTg0ZWY0OTljNjBmZmQ1MDM4ZWFkYzkwM2E1Y2U4NDZiY2YxYmU4NDc0MmJkY2ZjNDk3ZjhjOTQ5NzIyZDE3NTZkMzZkMGE2MmUyZDEzODcyNmQxZGE3OTIxYWU2ZGEwZDhjYjRjNjE0Yjk5YTczMjFkMmEzOGE0MTBhYWI5MmUsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpRME1ESXlOek0zTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0ozWldJaUxDSnNiMk5oYkdodmMzUWlYU3dpY0d4aGJpSTZJak0wSWl3aWMyTnZjR1VpT2xzaWRqY2lMQ0oyT0NJc0luWTVJaXdpZGpFd0lpd2lkakV4SWl3aVkyaGhjblJ6SWl3aVptOXliWE1pTENKbWIzSnRkV3hoSWl3aWNHRnljMlZ5SWl3aWNtVnVaR1Z5SWl3aVkyOXRiV1Z1ZEhNaUxDSnBiWEJ2Y25SbGNpSXNJbUpoY2lJc0luWmhiR2xrWVhScGIyNXpJaXdpYzJWaGNtTm9JaXdpY0hKcGJuUWlMQ0p6YUdWbGRITWlMQ0pqYkdsbGJuUWlMQ0p6WlhKMlpYSWlMQ0p6YUdGd1pYTWlYU3dpWkdWdGJ5STZkSEoxWlgwPQ==');
const data = [];
for (let j = 0; j < 50000; j++) {
data[j] = [];
for (let i = 0; i < 100; i++) {
data[j][i] = jspreadsheet.helpers.getColumnNameFromCoords(i, j);
}
}
let s = Date.now();
@Component({
selector: "app-root",
template: `<div #spreadsheet></div><div id="console"></div>`,
})
export class AppComponent {
@ViewChild("spreadsheet") spreadsheet: ElementRef;
worksheets: jspreadsheet.worksheetInstance[];
ngAfterViewInit() {
this.worksheets = jspreadsheet(this.spreadsheet.nativeElement, {
worksheets: [{
data: data,
tableOverflow: true,
tableWidth: '800px',
tableHeight: '300px',
}],
onload: function() {
let e = Date.now();
document.getElementById('console').innerText = 'The table was created in: ' + (e - s) + 'ms';
}
});
}
}