Spreadsheet Headers
This section covers the methods to handle with the spreadsheet headers.
Documentation
Section titled “Documentation”Methods
Section titled “Methods”The following methods are available to interact with the spreadsheet headers programmatically.
| Method | Description |
|---|---|
| getHeaders | Get the header title by column number. Jworksheet getHeaders(column?: number | number[]): Promise<string[]> @param column - get the header title by column number starting on zero. If no value is passed, returns the titles of all columns GET /api/:guid/:worksheetIndex/header/:columns |
| setHeader | Set a custom header title. @param title - new title @param column - column number starting on zero Jworksheet setHeader(column: number, title: string): Promise<void> POST /api/:guid/:worksheetIndex/header |
Examples
Section titled “Examples”How to change the title of a column
Section titled “How to change the title of a column”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);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
// Change the header title for the first columnworksheet .setHeader(0, "New title") .then(() => { // It worked correctly }) .catch((err) => { // Something went wrong console.log(err); });curl -X POST "http://localhost:8009/api/15eb1171-5a64-45bf-be96-f52b6125a045/0/header" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i" \ -H "Content-Type: application/json" \ -d '{ "column": 0, "title": "New title" }'Get the current column titles
Section titled “Get the current column titles”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);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
worksheet.getHeaders().then((titles) => { console.log(titles);});curl -X GET "http://localhost:8009/api/15eb1171-5a64-45bf-be96-f52b6125a045/0/header" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"Get the title from a specified column number
Section titled “Get the title from a specified column number”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);
// Get Jworksheet objectconst worksheet = spreadsheet.getWorksheet(0);
worksheet.getHeaders(1).then((titles) => { console.log(titles);});
// ["B"]curl -X GET "http://localhost:8009/api/15eb1171-5a64-45bf-be96-f52b6125a045/0/header/1" \ -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i"