Spreadsheet Data
Get and set data to and from your online spreadsheets.
Documentation
Section titled “Documentation”Methods
Section titled “Methods”The following methods are available to interact with the spreadsheet data programmatically.
| Method | Description |
|---|---|
| getData | Get the data from the worksheet Jworksheet getData(): Promise<(string | number | boolean | null)[][] | Record<string, string | number | boolean | null>[]> GET /api/:guid/:worksheetIndex/data |
| setData | Set a new data for your worksheet @param data - new data Jworksheet setData(data: string[][] | { row: number; data: string[]; }[]): Promise<void> POST /api/:guid/:worksheetIndex/data |
Examples
Section titled “Examples”Get the spreadsheet data
Section titled “Get the spreadsheet data”The following example show how to get the data from a worksheet.
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 = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// Get dataworksheet.getData().then((data) => { console.log(data);});curl -X GET "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/data" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"Set the spreadsheet data
Section titled “Set the spreadsheet data”The following example show how to update the data from a worksheet.
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 = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// Set Dataworksheet .setData([["1", "2", "3"]]) .then(() => { // It worked correctly }) .catch((err) => { // Something went wrong console.log(err); });curl -X POST "http://localhost:8009/api/79b45919-c751-4e2b-a49a-6c1286e2fc03/0/data" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i" \ -H "Content-Type: application/json" \ -d '{ "data": [["1", "2", "3"]] }'