Extract Theme Data from Excel File

JavaScript code to extract theme data from Excel file

The following sample code extracts the Theme name applied to the source workbook and then it extracts the Theme color applied to cell A1 and the Theme color applied to the bottom border of the cell.

const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "source.xlsx");
// Create workbook object
const workbook = new AsposeCells.Workbook(filePath);
// Extract theme name applied to this workbook
console.log(workbook.getTheme());
// Access first worksheet
const worksheet = workbook.getWorksheets().get(0);
// Access cell A1
const cell = worksheet.getCells().get("A1");
// Get the style object
const style = cell.getStyle();
if (style.getForegroundThemeColor() != null) {
// Extract theme color applied to this cell if theme has foreground theme color defined
console.log(style.getForegroundThemeColor().getColorType());
} else {
console.log("Theme has not foreground color defined.");
}
// Extract theme color applied to the bottom border of the cell if theme has border color defined
const bot = style.getBorders().getBorder(AsposeCells.BorderType.BottomBorder);
if (bot.getThemeColor() != null) {
console.log(bot.getThemeColor().getColorType());
} else {
console.log("Theme has not Border color defined.");
}