Rows
The following methods are available for rows operations.
Documentation
insertRow
Add one or more rows to the worksheet.
| Parameter | Description |
|---|---|
rows |
Position, data and options of new rows. |
POST /api/:guid/:worksheetIndex/rows/insert
moveRow
Move one or more rows.
| Parameter | Description |
|---|---|
from |
Index of the first row to be moved. |
to |
Index where rows should be moved to. |
quantity |
Number of rows to be moved. |
POST /api/:guid/:worksheetIndex/rows/move
deleteRow
Remove one or more rows.
| Parameter | Description |
|---|---|
rows |
Indexes of the rows to be removed. |
DELETE /api/:guid/:worksheetIndex/rows/:rowIndexes
setHeight
Update the row height.
| Parameter | Description |
|---|---|
row |
Row number. |
height |
New height. |
POST /api/:guid/:worksheetIndex/height
getHeight
Get the height of one or multiple rows.
| Parameter | Description |
|---|---|
rowNumber |
Row number. If omitted, returns the heights of all rows. |
GET /api/:guid/:worksheetIndex/height/:rows
setRowVisibility
Change the visibility of one or more rows.
| Parameter | Description |
|---|---|
rows |
Affected rows. |
visible |
Row visibility. |
POST /api/:guid/:worksheetIndex/rows/show
POST /api/:guid/:worksheetIndex/rows/hide
Examples
Insert rows
const baseUrl = 'http://localhost:8009/api';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
const headers = { 'Authorization': `Bearer ${token}` };
// Insert a row at position 1 of worksheet 0
await fetch(`${baseUrl}/${guid}/0/rows/insert`, {
method: 'POST',
headers,
body: new URLSearchParams({
'rows[0][row]': '1',
'rows[0][data][0]': 'Apple',
'rows[0][data][1]': '$3.442',
'rows[0][data][2]': 'USA',
}),
});
Row position
Change the row position, from the first to the second position.
const baseUrl = 'http://localhost:8009/api';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
const headers = { 'Authorization': `Bearer ${token}` };
// Move one row from position 0 to position 1
await fetch(`${baseUrl}/${guid}/0/rows/move`, {
method: 'POST',
headers,
body: new URLSearchParams({
'from': '0',
'to': '1',
'quantity': '1',
}),
});
Delete rows
const baseUrl = 'http://localhost:8009/api';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
const headers = { 'Authorization': `Bearer ${token}` };
// Delete the rows at indexes 1 and 3 of worksheet 0
await fetch(`${baseUrl}/${guid}/0/rows/1,3`, {
method: 'DELETE',
headers,
});
Row height
Define the height of a first row to 30px
const baseUrl = 'http://localhost:8009/api';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
const headers = { 'Authorization': `Bearer ${token}` };
// Set the height of the first row to 30px
await fetch(`${baseUrl}/${guid}/0/height`, {
method: 'POST',
headers,
body: new URLSearchParams({
'row': '0',
'height': '30',
}),
});
Define the height of multiple rows
const baseUrl = 'http://localhost:8009/api';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
const headers = { 'Authorization': `Bearer ${token}` };
// Set the height of the first three rows to 50px
await fetch(`${baseUrl}/${guid}/0/height`, {
method: 'POST',
headers,
body: new URLSearchParams({
'row[0]': '0',
'row[1]': '1',
'row[2]': '2',
'height': '50',
}),
});
Get the height of the first row
const baseUrl = 'http://localhost:8009/api';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
const headers = { 'Authorization': `Bearer ${token}` };
// Get the height of the first row
const heights = await (await fetch(`${baseUrl}/${guid}/0/height/0`, { headers })).json();
console.log(heights);
Get the height of multiple rows
const baseUrl = 'http://localhost:8009/api';
const token = 'eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i';
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';
const headers = { 'Authorization': `Bearer ${token}` };
// Get the heights of rows 2, 3 and 4
const heights = await (await fetch(`${baseUrl}/${guid}/0/height/2,3,4`, { headers })).json();
console.log(heights);