Can't find what you're looking for?

Contact us or post in our forums and we'll help you find an answer.

Highlight the last column of a table in Pure JavaScript

Background:

To highlight the last column of a table, utilize the table method highlightLastColumn to set an indicator to highlight the last column while the table is being added.

Steps to Complete:

1. Initialize SpreadJS and add a table from data source

2. Set highlightLastColumn to True

Getting Started:

Step 1: Initialize SpreadJS and a table from data source

For this example, add a range table from the data source using SpreadJS’s addFromDataSource method and store it in the variable called table.

Use the following parameters to create the table:

  • Table Name: table

  • Row:0

  • Col:0,

  • Data source: dataArray

  • Style: dark1

The final script tag should appear as so:

  <script></script>

After this step, the table will appear as so:

Step 2: Set highlightLastColumn to True

Underneath where we have added a table from the data source, set the highlightLastColumn method to True to indicate to highlight the first column.

 // Add table from data source
      var table = sheet.tables.addFromDataSource(
        "table",
        0,
        0,
        dataArray,
        GC.Spread.Sheets.Tables.TableThemes.dark1
      );
// Indicate to highlight the last column
       table.highlightLastColumn(true);

After this step, the table will will now how the last column highlighted like so: