Excel Themen und Farben
Wie man ein Farbschema in Excel erstellt und anwendet
Dokumentthemen erleichtern die Koordination von Farben, Schriftarten und grafischen Formatierungseffekten von Excel-Dokumenten und ermöglichen eine schnelle Aktualisierung.
Themen bieten ein einheitliches Erscheinungsbild mit benannten Stilen, grafischen Effekten und anderen Objekten, die in einer Arbeitsmappe verwendet werden. Zum Beispiel sieht der Accent1-Stil in den Office- und den Apex-Themen unterschiedlich aus. Oft wenden Sie ein Dokumententhema an und ändern es dann nach Wunsch.
Wie man ein Farbschema in Excel anwendet
- Öffnen Sie Excel und wechseln Sie zum Register „Seitenlayout“ im Excel-Band.
- Klicken Sie auf die Schaltfläche „Farben“ im Abschnitt „Themen“.
- Wählen Sie eine Farbpalette aus, die Ihren Anforderungen entspricht, oder fahren Sie mit der Maus über ein Schema, um eine Live-Vorschau anzuzeigen.
Wie man ein benutzerdefiniertes Farbschema in Excel erstellt
Sie können Ihre eigene Farbgebung erstellen, um Ihrem Dokument ein frisches, einzigartiges Aussehen zu verleihen oder den Markenstandards Ihrer Organisation zu entsprechen.
-
Öffnen Sie Excel und wechseln Sie zum Register „Seitenlayout“ im Excel-Band.
-
Klicken Sie auf die Schaltfläche „Farben“ im Abschnitt „Themen“.
-
Klicken Sie auf die Schaltfläche „Farben anpassen…“.
-
In dem Dialogfeld „Neue Designfarben erstellen“ können Sie für jedes Element Farben auswählen, indem Sie auf die Farbauswahlfelder neben ihnen klicken. Sie können Farben aus der Palette auswählen oder benutzerdefinierte Farben über die Option „Mehr Farben“ definieren.
-
Nach Auswahl aller gewünschten Farben geben Sie einen Namen für Ihr benutzerdefiniertes Farbschema im Feld „Name“ an.
-
Klicken Sie auf die Schaltfläche „Speichern“, um Ihr benutzerdefiniertes Farbschema zu speichern. Ihr benutzerdefiniertes Farbschema steht jetzt im Drop-Down-Menü „Farben“ für zukünftige Verwendungen zur Verfügung.
Wie man ein Farbschema in Aspose.Cells erstellt und anwendet
Aspose.Cells bietet Funktionen zur Anpassung von Themen und Farben.
Wie man ein benutzerdefiniertes Farbdesign in Aspose.Cells erstellt
Wenn im Dokument Themenfarben verwendet werden, müssen wir nicht jede Zelle einzeln ändern; wir müssen nur die Farben im Thema ändern.
Das folgende Beispiel zeigt, wie benutzerdefinierte Designs mit den gewünschten Farben angewendet werden. Es wird eine Beispieldatei verwendet, die manuell in Microsoft Excel 2007 erstellt wurde.
Das folgende Beispiel lädt eine Vorlage XLSX-Datei, definiert Farben für verschiedene Theme-Farbtypen, wendet die benutzerdefinierten Farben an und speichert die Excel-Datei.
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, "book1.xlsx"); | |
// Define Color array (of 12 colors) for Theme. | |
const carr = [ | |
new AsposeCells.Color("AntiqueWhite"), // Background1 | |
new AsposeCells.Color("Brown"), // Text1 | |
new AsposeCells.Color("AliceBlue"), // Background2 | |
new AsposeCells.Color("Yellow"), // Text2 | |
new AsposeCells.Color("YellowGreen"), // Accent1 | |
new AsposeCells.Color("Red"), // Accent2 | |
new AsposeCells.Color("Pink"), // Accent3 | |
new AsposeCells.Color("Purple"), // Accent4 | |
new AsposeCells.Color("PaleGreen"), // Accent5 | |
new AsposeCells.Color("Orange"), // Accent6 | |
new AsposeCells.Color("Green"), // Hyperlink | |
new AsposeCells.Color("Gray") // Followed Hyperlink | |
]; | |
// Instantiate a Workbook. | |
// Open the template file. | |
const workbook = new AsposeCells.Workbook(filePath); | |
// Set the custom theme with specified colors. | |
workbook.customTheme("CustomeTheme1", carr); | |
// Save as the excel file. | |
workbook.save(path.join(dataDir, "output.out.xlsx")); |
So wenden Sie Designs in Aspose.Cells an
Das folgende Beispiel wendet die Vordergrund- und Schriftfarben einer Zelle basierend auf den Standard-Theme-Farbtypen an. Es speichert auch die Excel-Datei auf der Festplatte.
const path = require("path"); | |
const AsposeCells = require("aspose.cells.node"); | |
// The path to the documents directory. | |
const dataDir = path.join(__dirname, "data"); | |
// Create directory if it is not already present. | |
if (!require("fs").existsSync(dataDir)) { | |
require("fs").mkdirSync(dataDir); | |
} | |
// Instantiate a Workbook. | |
const workbook = new AsposeCells.Workbook(); | |
// Get cells collection in the first (default) worksheet. | |
const cells = workbook.getWorksheets().get(0).getCells(); | |
// Get the D3 cell. | |
const c = cells.get("D3"); | |
// Get the style of the cell. | |
const s = c.getStyle(); | |
// Set foreground color for the cell from the default theme Accent2 color. | |
s.setForegroundThemeColor(new AsposeCells.ThemeColor(AsposeCells.ThemeColorType.Accent2, 0.5)); | |
// Set the pattern type. | |
s.setPattern(AsposeCells.BackgroundType.Solid); | |
// Get the font for the style. | |
const f = s.getFont(); | |
// Set the theme color. | |
f.setThemeColor(new AsposeCells.ThemeColor(AsposeCells.ThemeColorType.Accent4, 0.1)); | |
// Apply style. | |
c.setStyle(s); | |
// Put a value. | |
c.putValue("Testing1"); | |
// Save the excel file. | |
workbook.save(path.join(dataDir, "output.out.xlsx")); |
So erhalten und setzen Sie Designs in Aspose.Cells
Nachfolgend finden Sie einige Methoden und Eigenschaften, die Designs implementieren.
- Style.setForegroundThemeColor: Wird verwendet, um die Vordergrundfarbe festzulegen.
- Style.setBackgroundThemeColor: Wird verwendet, um die Hintergrundfarbe festzulegen.
- Font.setThemeColor: Wird verwendet, um die Schriftfarbe festzulegen.
- Workbook.getThemeColor: Wird verwendet, um eine Thema-Farbe zu erhalten.
- Workbook.setThemeColor: Wird verwendet, um eine Thema-Farbe festzulegen.
Das folgende Beispiel zeigt, wie Designs erhalten und gesetzt werden.
Das folgende Beispiel verwendet eine Vorlage XLSX-Datei, erhält die Farben für verschiedene Theme-Farbtypen, ändert die Farben und speichert die Microsoft Excel-Datei.
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, "book1.xlsx"); | |
// Instantiate Workbook object. | |
// Open an existing excel file. | |
const workbook = new AsposeCells.Workbook(filePath); | |
// Get the Background1 theme color. | |
let c = workbook.getThemeColor(AsposeCells.ThemeColorType.Background1); | |
// Print the color. | |
console.log("theme color Background1: ", c); | |
// Get the Accent2 theme color. | |
c = workbook.getThemeColor(AsposeCells.ThemeColorType.Accent2); | |
// Print the color. | |
console.log("theme color Accent2: ", c); | |
// Change the Background1 theme color. | |
workbook.setThemeColor(AsposeCells.ThemeColorType.Background1, AsposeCells.Color.Red); | |
// Get the updated Background1 theme color. | |
c = workbook.getThemeColor(AsposeCells.ThemeColorType.Background1); | |
// Print the updated color for confirmation. | |
console.log("theme color Background1 changed to: ", c); | |
// Change the Accent2 theme color. | |
workbook.setThemeColor(AsposeCells.ThemeColorType.Accent2, AsposeCells.Color.Blue); | |
// Get the updated Accent2 theme color. | |
c = workbook.getThemeColor(AsposeCells.ThemeColorType.Accent2); | |
// Print the updated color for confirmation. | |
console.log("theme color Accent2 changed to: ", c); | |
// Save the updated file. | |
workbook.save(path.join(dataDir, "output.out.xlsx")); |