Themendaten aus Excel Datei extrahieren
Aspose.Cells ermöglicht es den Benutzern, theme-bezogene Daten aus Excel-Dateien zu extrahieren. Zum Beispiel können Sie den angewendeten Themen-Namen auf die Arbeitsmappe und die angewendete Themenfarbe auf die Zelle oder die Rahmen der Zelle extrahieren, usw.
Sie können ein Thema auf Ihre Arbeitsmappe anwenden, indem Sie Microsoft Excel über den Befehl Seite Layout > Themen verwenden.
JavaScript-Code zum Extrahieren von Theme-Daten aus Excel-Datei
Das folgende Beispiel zeigt, wie man den angewendeten Theme-Namen aus der Quelarbeitsmappe extrahiert und dann die Theme-Farbe auf Zelle A1 sowie die Theme-Farbe für den unteren Rand der Zelle extrahiert.
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."); | |
} |