Skip to content

Intrasheets

This section explores Intrasheets' flexibility for building and customizing the front end, including custom layouts, interactive controls, and integration of spreadsheets with applications and custom functions.

npm install intrasheets;

To use the CDN, load Intrasheets and its dependencies as shown below.

<!-- Dependencies -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/jspreadsheet@11/dist/jspreadsheet.min.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/jsuites@5/dist/jsuites.min.css" rel="stylesheet" />
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/socket.io.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/pdf-lib/dist/pdf-lib.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jspreadsheet@11/dist/index.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jsuites@5/dist/index.min.js"></script>
<!-- Intrasheets -->
<link href="https://cdn.jsdelivr.net/npm/intrasheets@3/dist/style.min.css" rel="stylesheet" />
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/intrasheets@3/dist/index.min.js"></script>

The following properties are available:

PropertyDescription
loadAlias for jspreadsheet(DOM, options).
listCalls the API to retrieve a list of spreadsheets created by the user defined in the JWT token.

The following properties can be configured to customize your Intrasheets interface.

PropertyDescription
client: objectConfiguration settings for the server connection
bar?: objectSettings for the edition bar extension
comments?: objectSettings for the comments extension
google? objectSettings for google sheets importer
PropertyDescription
url: stringURL of your Intrasheets server.
auth?: objectAuthentication attributes shared with the server, typically including token, invitation, and any custom attributes.
onerror?: functionFunction to handle error messages displayed to the user.
onbeforeloadimage?: functionEvent for customizing image loading behavior.
MethodDescription
clientId?: stringGoogle Sheets API Client ID
apiKey?: stringGoogle Sheets API key
errorUri?: stringURI for handling API errors
redirectUri?: stringRedirect URI for the API

A simple example using

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/jspreadsheet@11/dist/jspreadsheet.min.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/jsuites@5/dist/jsuites.min.css" rel="stylesheet" />
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/socket.io.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/pdf-lib/dist/pdf-lib.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jspreadsheet@11/dist/index.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jsuites@5/dist/jsuites.min.js"></script>
<!-- Intrasheets -->
<link href="https://cdn.jsdelivr.net/npm/intrasheets@3/dist/style.min.css" rel="stylesheet" />
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/intrasheets@3/dist/index.min.js"></script>
<div id="root"></div>
<script>
function Sheets(token, invitation) {
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense(license);
// Register the extension
jspreadsheet.setExtensions({ intrasheets });
// Start intrasheets
intrasheets({
google: {
clientId: 'yourClientId.apps.googleusercontent.com',
apiKey: 'yourApiKey',
redirectUri: 'http://localhost:8000/sheets',
errorUri: 'http://localhost:8000/sheets/error',
},
bar: {
suggestions: true
},
client: {
url: 'http://localhost:3009',
auth: {
token: token,
invitation: invitation
},
onerror: function (e) {
console.error(e);
},
onbeforeloadimage: function (worksheet, img, options) {
// Image should be loaded from the API
if (options.src.includes('/api')) {
// Intercept the images load to get those from the S3
fetch('http://localhost:3009' + options.src, {
headers: {
'Authorization': `Bearer ${token},${invitation}`
}
})
.then(response => {
// Convert the response to a blob
return response.blob();
})
.then(blob => {
// Create and return a URL for the blob
img.src = URL.createObjectURL(blob);
});
// Do not load images until the download is ready
return false;
}
},
}
})
// Start application
if (guid && guid.length === 36) {
// Open the spreadsheet
jspreadsheet(document.getElementById('root'), {
guid: guid
});
} else {
// List all spreadsheets save for one user
intrasheets.list(document.getElementById('root'));
}
}
</script>
const jspreadsheet = require('jspreadsheet');
const intrasheets = require('intrasheets');
require('jsuites/dist/jsuites.css');
require('jspreadsheet/dist/jspreadsheet.css');
require('intrasheets/dist/style.css');
const license = 'yourLicenseKey';
function Sheets(token, invitation) {
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense(license);
// Register the extension
jspreadsheet.setExtensions({ intrasheets });
// Start intrasheets
intrasheets({
google: {
clientId: 'yourClientId.apps.googleusercontent.com',
apiKey: 'yourApiKey',
redirectUri: 'http://localhost:8000/sheets',
errorUri: 'http://localhost:8000/sheets/error',
},
bar: {
suggestions: true
},
client: {
url: 'http://localhost:3009',
auth: {
token: token,
invitation: invitation
},
onerror: function (e) {
console.error(e);
},
onbeforeloadimage: function (worksheet, img, options) {
// Image should be loaded from the API
if (options.src.includes('/api')) {
// Intercept the images load to get those from the S3
fetch('http://localhost:3009' + options.src, {
headers: {
'Authorization': `Bearer ${token},${invitation}`
}
})
.then(response => {
// Convert the response to a blob
return response.blob();
})
.then(blob => {
// Create and return a URL for the blob
img.src = URL.createObjectURL(blob);
});
// Do not load images until the download is ready
return false;
}
},
}
})
// Start application
if (guid && guid.length === 36) {
// Open the spreadsheet
jspreadsheet(document.getElementById('root'), {
guid: guid
});
} else {
// List all spreadsheets save for one user
intrasheets.list(document.getElementById('root'));
}
}

Intrasheets Server allows full customization of authorization by passing properties to the server through the client.auth object. The standard setup uses tokens and invitations, but developers can adapt this to handle any authentication data processed through server-side events for complete flexibility.

More about the server authentication


The example above uses the client.onbeforeloadimage event to load images stored externally, such as on S3, ensuring they are loaded correctly.

More about image managment