Rows
The following methods are available for rows operations.Documentation
Methods
The following methods are available to interact with the spreadsheet headers programmatically.Method | Description |
---|---|
getRow | Get a row data. @param rowNumber - row number Jspreadsheet getRow(rowNumber: number | number[]): Promise<{ row: number; data: string[] }[]> GET /api/:guid/rows/:rows
|
insertRow | Insert a new row. @param numOfRows - number of rows that must be inserted. Default is 1. @param rowNumber - reference row for insertion. Default is the last row. @param insertBefore - insert before or after reference line. Default is false. @param data - row instructions object. New row values. Jspreadsheet insertRow(options?: { numOfRows?: number; rowNumber?: number; insertBefore?: boolean; data?: ({ data: { [key: string]: string } | string[] } | { [key: string]: string } | string[] )[] }): Promise<{ numOfRows: number, rowNumber: number, insertBefore: boolean, data: { row: number, data: string[] } }> POST /api/:guid/rows
|
moveRow | Change the row position. @param from - row number. @param to - to the position. Jspreadsheet moveRow(from: number, to: number): Promise<void> POST /api/:guid/rows/move
|
deleteRow | Delete rows. @param rowNumber - row number. @param numOfRows - number of rows. Default is 1. Jspreadsheet deleteRow(rowNumber: number, numOfRows?: number): Promise<void> POST /api/:guid/rows/delete
|
setHeight | Update the row height. @param row - row number. @param height - new height. Jspreadsheet setHeight(row: number | number[], height: number | number[]): Promise<void> POST /api/:guid/height
|
getHeight | Get the height of one or multiple rows. @param rowNumber - row number. If omitted, returns the heights of all rows. Jspreadsheet getHeight(rowNumber?: number | number[]): Promise<{ [rowNumber: string]: number }> GET /api/:guid/height
|
Examples
Insert rows
Add a new row at the end of the spreadsheet
import { Client } from "@intrasheets/client"; // Create a new client const client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i", }); // Spreadsheet Guid const guid = '15eb1171-5a64-45bf-be96-f52b6125a045'; // Get the spreadsheet instance const spreadsheet = client.getSpreadsheet(guid); const data = [['Apple', '$3.442', 'USA']]; // Insert data spreadsheet.insertRow({ data }).then((result) => { console.log(result); }); // { // numOfRows: 1, // rowNumber: 5, // insertBefore: 0, // data: [{ // id: 5075, // row: 6, // data: [ // "Apple", // "$3.442", // "USA", // ], // }], // }
Adding a new row after line 5
import { Client } from "@intrasheets/client"; // Create a new client const client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i", }); // Spreadsheet Guid const guid = '15eb1171-5a64-45bf-be96-f52b6125a045'; // Get the spreadsheet instance const spreadsheet = client.getSpreadsheet(guid); const data = [['1', '2', '3'], ['4', '5', '6']]; // Insert data spreadsheet.insertRow({ rowNumber: 5, insertBefore: false, data }).then((result) => { console.log(result); }); // { // numOfRows: 2, // rowNumber: 5, // insertBefore: 0, // data: [ // { id: 5077, row: 6, data: ["1", "2", "3"]}, // { id: 5078, row: 7, data: ["4", "5", "6"]} // ] // }
Row position
Change the row position, from the first to the second position.
import { Client } from "@intrasheets/client"; // Create a new client const client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i", }); // Spreadsheet Guid const guid = '15eb1171-5a64-45bf-be96-f52b6125a045'; // Get the spreadsheet instance const spreadsheet = client.getSpreadsheet(guid); spreadsheet.moveRow(0, 1).then(() => { // It worked correctly }).catch((err) => { // Something went wrong console.log(err); });
Delete rows
Delete the first row
import { Client } from "@intrasheets/client"; // Create a new client const client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i", }); // Spreadsheet Guid const guid = '15eb1171-5a64-45bf-be96-f52b6125a045'; // Get the spreadsheet instance const spreadsheet = client.getSpreadsheet(guid); // Delete the first row spreadsheet.deleteRow(0).then(() => { // It worked correctly }) .catch((err) => { // Something went wrong console.log(err); });
Delete rows 4,5,6
import { Client } from "@intrasheets/client"; // Create a new client const client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i", }); // Spreadsheet Guid const guid = '15eb1171-5a64-45bf-be96-f52b6125a045'; // Get the spreadsheet instance const spreadsheet = client.getSpreadsheet(guid); // Delete three rows from the forth column spreadsheet.deleteRow(3, 3).then(() => { // It worked correctly }) .catch((err) => { // Something went wrong console.log(err); });
Row height
Define the height of a first row to 30px
import { Client } from "@intrasheets/client"; // Create a new client const client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i", }); // Spreadsheet Guid const guid = '15eb1171-5a64-45bf-be96-f52b6125a045'; // Get the spreadsheet instance const spreadsheet = client.getSpreadsheet(guid); // Set the height spreadsheet.setHeight(0, 30).then(() => { // It worked correctly }) .catch((err) => { // Something went wrong console.log(err); });
Define the height of multiple rows
import { Client } from "@intrasheets/client"; // Create a new client const client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i", }); // Spreadsheet Guid const guid = '15eb1171-5a64-45bf-be96-f52b6125a045'; // Get the spreadsheet instance const spreadsheet = client.getSpreadsheet(guid); // Set the height spreadsheet.setHeight([0, 1, 2], 50).then(() => { // It worked correctly }) .catch((err) => { // Something weng wrong console.log(err); });
Get the height of the first row
import { Client } from "@intrasheets/client"; // Create a new client const client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i", }); // Spreadsheet Guid const guid = '15eb1171-5a64-45bf-be96-f52b6125a045'; // Get the spreadsheet instance const spreadsheet = client.getSpreadsheet(guid); // Result spreadsheet.getHeight(0).then((heights) => { console.log(heights); }); // { // "0": { // height: 30 // } // }
Get the height of multiple rows
import { Client } from "@intrasheets/client"; // Create a new client const client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i", }); // Spreadsheet Guid const guid = '15eb1171-5a64-45bf-be96-f52b6125a045'; // Get the spreadsheet instance const spreadsheet = client.getSpreadsheet(guid); // Result spreadsheet.getHeight([2, 3, 4]).then((heights) => { console.log(heights); }); // { // "1": { height: 50 }, // "2": { height: 142 }, // "3": { height: 175 }, // }
Row data
Get the data from multiple rows
import { Client } from "@intrasheets/client"; // Create a new client const client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i", }); // Spreadsheet Guid const guid = '15eb1171-5a64-45bf-be96-f52b6125a045'; // Get the spreadsheet instance const spreadsheet = client.getSpreadsheet(guid); // Result spreadsheet.getRow([0, 1]).then((rows) => { console.log(rows); }); // [ // { // row: 0, data: ["b", "a", "", "1", "sdfg"] // }, // { // row: 1, data: ["", "", "", "1", ""] // }, // ]
Get data from the first row
import { Client } from "@intrasheets/client"; // Create a new client const client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i", }); // Spreadsheet Guid const guid = '15eb1171-5a64-45bf-be96-f52b6125a045'; // Get the spreadsheet instance const spreadsheet = client.getSpreadsheet(guid); // Result spreadsheet.getRow(0).then((rows) => { console.log(rows); }); // [ // { // row: 0, data: ["b", "a", "", "1", "sdfg"] // }, // ]