Skip to content

Client Class

The client class is essential for using the client API, being the only class exported by the API.

O construtor da classe Client possui apenas um argumento, o objeto options, que possui duas propriedades:

PropertyDescription
options.baseUrlUrl of the server to which the Client object and any Jspreadsheet and Jworksheet objects generated from it will send requests.
If omitted, the value of the environment variable JSPREADSHEET_API_BASE_URL is used and, if this is also not set, the default value "https://jspreadsheet.com/api" is used.
options.tokenAccess token for the server informed in the options.baseUrl property. This value can be omitted, but in this case, some services may not work due to lack of authentication.

Generates a Jspreadsheet object based on the spreadsheet guid.

getSpreadsheet(guid: string): IJspreadsheet;
PropertyDescription
guidSpreadsheet Guid.
import { Client } from "@intrasheets/client";
const client = new Client({
baseUrl: "[Server url]",
token: "[Your access token]",
});
const spreadsheet = client.getSpreadsheet(
"6b1842a1-f737-4492-b6c4-e54a25643fb7",
);
spreadsheet.getConfig().then((config) => console.log(config));

Creates a new spreadsheet and then returns a Jspreadsheet object referring to it.

createSpreadsheet(
config: Omit<Spreadsheet, "worksheets"> & {
worksheets: (Omit<Worksheet, "worksheetName"> &
Required<Pick<Worksheet, "worksheetName">>)[];
}
): Promise<IJspreadsheet>;
PropertyDescription
configSpreadsheet Settings.

Obs: Ao criar uma spreadsheet, ela deve ter pelo menos uma worksheet, e todas as worksheets devem ter um worksheetName.

import { Client } from "@intrasheets/client";
const client = new Client({
baseUrl: "[Server url]",
token: "[Your access token]",
});
client
.createSpreadsheet({
worksheets: [
{
minDimensions: [10, 10],
worksheetName: 'test'
},
],
})
.then((spreadsheet) => {
console.log(spreadsheet.getSpreadsheetGuid());
});