Spreadsheet Sharing
Jspreadsheet Server supports spreadsheet sharing via direct links or embeddable snippets. It allows flexible access control by enabling developers to implement custom rules based on ownership, privacy, invitation status, or any other logic required.
Sharing via link
You can enable spreadsheet sharing through links with token-based authentication. When a user opens a shared link, the server can validate if the user is:
- The document owner
- A user with a valid invitation
- A public viewer
These rules are handled on the server side using events like onbeforeload
. You can define any custom access validation based on your needs.
Inviting a new user
Jspreadsheet offers a built-in interface to manage invitations. When adding a new user, the system generates a unique invitation token.
You can add users through the interface or via the API extension.
1. Invitation Token
The token is a unique hash added to the spreadsheet URL. It’s used by the server to validate user access.
For more on this, refer to the Authentication Methods.
Example:
https://yourdomain.com/sheets/4b8bd2c1-f3c4-4c36-b4ec-e5e3fb15f1e7/27aff468
2. Token Structure
The token is typically stored in the spreadsheet object’s users
array:
{
spreadsheet: {}
users: [
{
email: '[email protected]',
level: 0, // 0 = viewer, 1 = editor, 2 = owner
token: '27aff468'
}
]
}
Embedding Spreadsheets
Public spreadsheets can be embedded into external websites using a code snippet generated by the Jspreadsheet interface. This allows users to view (and optionally interact with) a spreadsheet directly within another webpage.
You can generate this embed code directly in the application.