Style
Manage the cell style using the following methods.
Documentation
Section titled “Documentation”Methods
Section titled “Methods”Available methods for cell style management.
| Method | Description |
|---|---|
| getStyle | Get the style information from one or more cells. @param cellNames - cell names and/or ranges. If omitted, returns styles for all cells. Jspreadsheet getStyle(cellNames?: string): Promise<{ [cellName: string]: string }> GET /api/:guid/style |
| setStyle | Apply or remove styles from one or more cells @param styles[].cellName - name of the cell to be styled. @param styles[].value - new cell styles. If a style property is sent without a value (with just blank spaces), it will be removed. Jspreadsheet setStyle(styles: { cellName: string; value: string }[]): Promise<void> POST /api/:guid/style |
| removeStyle | Remove all styles from one or more cells. @param cellNames - cell names and/or ranges. Jspreadsheet removeStyle(cellNames: string): Promise<void> DELETE /api/:guid/style |
Examples
Section titled “Examples”Set style
Section titled “Set style”Define style to the spreadsheet cells.
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 = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// New stylesconst styles = [ { cellName: "A1", value: "background-color: #333;color:#fff;", }, { cellName: "A2", value: "background-color: #ccc", },];
// Apply stylespreadsheet.setStyle(styles).then(() => { // It worked correctly}).catch((err) => { console.log(err);});Reset style
Section titled “Reset style”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 = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Reset A1,A2,A3 or A1:A3 for multiple cellsspreadsheet.removeStyle("A1").then(() => { // It worked correctly}).catch((err) => { // Something went wrong console.log(err);});