Extrahera temadata från Excel fil
Aspose.Cells tillåter användarna att extrahera temarelaterade data från Excel-filen. Till exempel kan du extrahera temanamn som tillämpas på arbetsboken och temafärg som tillämpas på cellen eller cellernas ramar etc.
Du kan tillämpa tema på din arbetsbok med hjälp av Microsoft Excel via kommandot Sidlayout > Teman.
JavaScript-kod för att extrahera temadata från Excel-fil
Följande exempel kod extraherar Temats namn som är tillämpat på kälboken och sedan hämtar det Temafärg som tillämpats på cell A1 och Temafärgen som är tillämpad på cellens bottenkant.
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."); | |
} |