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.
MethodDescription
getHeaders Get the header title by column number. Null for all columns.
getHeaders(column?: number | number[]): Promise<{ [column: number]: 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/header
setHeader Set a custom header title.
setHeader(column: number, title: string): Promise<void>
@param column - column number starting on zero
@param title - new title

POST /api/:guid/header


Examples

Set a column title


NodeJS
PHP
import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create a new client
const client = new Client(token);

// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);

// Set title
spreadsheet.setHeader(0, "New title").then(() => {
    // It worked correctly
})
.catch((err) => {
    // Something went wrong
    console.log(err);
});
<?php
// Access token
$token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
$guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create the client instance
$client = new Jspreadsheet($token);

// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);

// Result
$data = $spreadsheet->setHeader(0, 'New title');

print_r($data);

// Array ( [success] => 1 [message] => Updated [data] => )

Get all column titles


NodeJS
PHP
import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create a new client
const client = new Client(token);

// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);

spreadsheet.getHeader().then((titles) => {
    console.log(titles);
});

// {
//     "0": "New title",
//     "1": "B",
//     "2": "C",
// }
<?php
require 'vendor/autoload.php';

use jspreadsheet\Jspreadsheet;

// Access token
$token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
$guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create the client instance
$client = new Jspreadsheet($token);

// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);

print_r($spreadsheet->getHeaders());

// ["New title","B","C","D","E","F","G","H","I","J"]

Get the title from a specified column number


NodeJS
PHP
import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create a new client
const client = new Client(token);

// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);

spreadsheet.getHeader(1).then((titles) => {
    console.log(titles);
});

// { "1": "B" }
<?php
require 'vendor/autoload.php';

use jspreadsheet\Jspreadsheet;

// Access token
$token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
$guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create the client instance
$client = new Jspreadsheet($token);

// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);

// Result
print_r($spreadsheet->getHeaders(1));

// Array ( [1] => B )



Create applications with spreadsheet-like controls