Spreadsheet Headers
This section covers the methods to handle with the spreadsheet headers.
Documentation
Methods
The following methods are available to interact with the spreadsheet headers programmatically.
Method | Description |
---|---|
getHeaders | Get the header title by column number. Null for all columns. `Jspreadsheet getHeaders(column?: number |
setHeader | Set a custom header title. @param title - new title @param column - column number starting on zero Jspreadsheet setHeader(column: number, title: string): Promise<void> POST /api/:guid/header |
Examples
How to change the title of a column
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);
// Change the header title for the first column
spreadsheet.setHeader(0, "New title").then(() => {
// It worked correctly
}).catch((err) => {
// Something went wrong
console.log(err);
});
Get the current column titles
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.getHeaders().then((titles) => {
console.log(titles);
});
// {
// "0": "New title",
// "1": "B",
// "2": "C",
// }
Get the title from a specified column number
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.getHeaders(1).then((titles) => {
console.log(titles);
});
// { "1": "B" }