Rows
The following methods are available for rows operations.
Documentation
Section titled “Documentation”Methods
Section titled “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 |
| 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 } |
| 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 |
| 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 |
Examples
Section titled “Examples”Insert rows
Section titled “Insert rows”Add a new row at the end of the spreadsheet
Section titled “Add a new row at the end of the 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);
const data = [['Apple', '$3.442', 'USA']];
// Insert dataspreadsheet.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
Section titled “Adding a new row after line 5”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);
const data = [['1', '2', '3'], ['4', '5', '6']];
// Insert dataspreadsheet.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
Section titled “Row position”Change the row position, from the first to the second position.
Section titled “Change the row position, from the first to the second position.”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.moveRow(0, 1).then(() => { // It worked correctly}).catch((err) => { // Something went wrong console.log(err);});Delete rows
Section titled “Delete rows”Delete the first row
Section titled “Delete the first row”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);
// Delete the first rowspreadsheet.deleteRow(0).then(() => { // It worked correctly}).catch((err) => { // Something went wrong console.log(err);});Delete rows 4,5,6
Section titled “Delete rows 4,5,6”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);
// Delete three rows from the forth columnspreadsheet.deleteRow(3, 3).then(() => { // It worked correctly}).catch((err) => { // Something went wrong console.log(err);});Row height
Section titled “Row height”Define the height of a first row to 30px
Section titled “Define the height of a first row to 30px”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);
// Set the heightspreadsheet.setHeight(0, 30).then(() => { // It worked correctly}).catch((err) => { // Something went wrong console.log(err);});Define the height of multiple rows
Section titled “Define the height of multiple rows”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);
// Set the heightspreadsheet.setHeight([0, 1, 2], 50).then(() => { // It worked correctly}).catch((err) => { // Something weng wrong console.log(err);});Get the height of the first row
Section titled “Get the height of the first row”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);
// Resultspreadsheet.getHeight(0).then((heights) => { console.log(heights);});
// {// "0": {// height: 30// }// }Get the height of multiple rows
Section titled “Get the height of multiple rows”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);
// Resultspreadsheet.getHeight([2, 3, 4]).then((heights) => { console.log(heights);});
// {// "1": { height: 50 },// "2": { height: 142 },// "3": { height: 175 },// }Row data
Section titled “Row data”Get the data from multiple rows
Section titled “Get the data from multiple rows”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);
// Resultspreadsheet.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
Section titled “Get data from the first row”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);
// Resultspreadsheet.getRow(0).then((rows) => { console.log(rows);});
// [// {// row: 0, data: ["b", "a", "", "1", "sdfg"]// },// ]