Spreadsheet
The following methods helps with the management of basic spreadsheet features.
Documentation
Section titled “Documentation”Methods
Section titled “Methods”The following methods are available to interact with the spreadsheet headers programmatically.
| Method | Description |
|---|---|
| getSpreadsheet | Get a Jspreadsheet object. This is an internal method of the client api and does not reflect any changes to the spreadsheet. Client getSpreadsheet(guid: string, worksheetIndex?: number): IJspreadsheet @param guid - spreadsheet guid. @param worksheetIndex - worksheet position. |
| create | Create a new spreadsheet and return its Jspreadsheet object. @param options.description - new spreadsheet name. @param options.config - new spreadsheet settings. `Client create(options?: { description?: string, config?: Partial |
| listSpreadsheets | List spreadsheets owned by or shared with the user. @param options.offset - number of spreadsheets skipped when performing the search. Default: 0. @param options.limit - maximum number of spreadsheets returned by the search. If not informed, all results found will be returned.. @param options.invitations - Also search for spreadsheets where the user is invited. Default: false. Client listSpreadsheets(options?: { offset?: number; limit?: number; invitations?: boolean; }): Promise<{ sheet_guid: string; sheet_description: string; sheet_updated: string; sheet_status: number; sheet_privacy: number; }[]> GET /api/list |
| getNewSignature | Generate a new access signature. @param token - Specific token for that route. Client getNewSignature(token: string): Promise<string> GET /api/signature |
| getSheetIdWithInvitation | Get the spreadsheet id with a guest token. @param token - Specific token for that route. Client getSheetIdWithInvitation(token: string): Promise<string> GET /api/invitation |
| delete | Delete a existing spreadsheet. Jspreadsheet delete() : Promise<void> DELETE /api/:guid |
| setName | Set the title of the spreadsheet. Jspreadsheet setName(name?: string): Promise<void> @param name - new title of the spreadsheet. POST /api/:guid/name |
Examples
Section titled “Examples”Create spreadsheet
Section titled “Create spreadsheet”import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Options for the new spreadsheet @See Jspreadsheet documentation for more optionsconst options = { description: 'My spreadsheet', config: { minDimensions: [10, 10], }};
// Create a new spreadsheetclient.create(options).then(async (newSpreadsheet) => { // Result 'My spreadsheet' console.log(await newSpreadsheet.getName());});List spreadsheets
Section titled “List spreadsheets”import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
client.listSpreadsheets().then((result) => { // User spreadsheets console.log(result);});Delete spreadsheet
Section titled “Delete spreadsheet”import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
spreadsheet.delete().then(() => { console.log('Spreadsheet removed');});Set the spreadsheet name
Section titled “Set the spreadsheet name”import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
spreadsheet.setName("New name").then(() => { console.log("Name changed");});