Set Worksheet Tab Color with Node.js via C++

Setting Worksheet Tab Color with Microsoft Excel

  1. Right‑click a tab on the sheet tab bar at the bottom of the workbook.
  2. Select Tab Color.
  3. Choose a color from the palette.
  4. Click OK.

Setting Worksheet Tab Color with Aspose.Cells

The sample code below shows how to set the tab color with Aspose.Cells.

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");

// Instantiate a new Workbook
// Open an Excel file
const workbook = new AsposeCells.Workbook(path.join(dataDir, "Book1.xlsx"));

// Get the first worksheet in the book
const worksheet = workbook.getWorksheets().get(0);

// Set the tab color
worksheet.setTabColor(AsposeCells.Color.Red);

// Save the Excel file
workbook.save(path.join(dataDir, "worksheettabcolor.out.xls"));