Temi e Colori di Excel

Come Applicare e Creare uno Schema Colori in Excel

I temi del documento facilitano il coordinamento dei colori, dei caratteri e degli effetti di formattazione grafica dei documenti di Excel e consentono di aggiornarli rapidamente.
I temi offrono un aspetto unificato con stili nominati, effetti grafici e altri oggetti utilizzati in un workbook. Ad esempio, lo stile Accent1 appare diverso nei temi Office e Apex. Spesso, si applica un tema al documento e poi lo si modifica secondo le preferenze.

Come Applicare uno Schema Colori in Excel

  1. Apri Excel e vai alla scheda “Layout di pagina” nel nastro di Excel.
  2. Fai clic sul pulsante “Colori” nella sezione “Temi”.


  3. Scegli una combinazione di colori che corrisponda alle tue esigenze o passa il mouse su uno schema per vedere un’anteprima in tempo reale.

Come creare un set di colori personalizzato in Excel

Puoi creare il tuo set di colori per dare al tuo documento un aspetto fresco e unico o per conformarti agli standard del marchio della tua organizzazione.

  1. Apri Excel e vai alla scheda “Layout di pagina” nel nastro di Excel.

  2. Fai clic sul pulsante “Colori” nella sezione “Temi”.

  3. Fai clic sul pulsante “Personalizza colori…”.


  4. Nella finestra di dialogo “Crea nuovi colori tema”, puoi selezionare i colori per ciascun elemento facendo clic sul menù a discesa accanto ad essi. Puoi scegliere i colori dalla palette o definire colori personalizzati utilizzando l’opzione “Altri colori”.


  5. Dopo aver selezionato tutti i colori desiderati, fornisci un nome per il tuo set di colori personalizzato nel campo “Nome”.

  6. Fai clic sul pulsante “Salva” per salvare il tuo set di colori personalizzato. Il tuo set di colori personalizzato sarà ora disponibile nel menù a discesa “Colori” per un uso futuro.

Come creare e applicare un set di colori in Aspose.Cells

Aspose.Cells offre funzionalità per personalizzare temi e colori.

Come creare un tema di colori personalizzato in Aspose.Cells

Se nel file sono utilizzati i colori del tema, non è necessario modificare ogni cella singolarmente; basta modificare i colori nel tema.

Nell’esempio seguente viene mostrato come applicare temi personalizzati con i colori desiderati. Utilizziamo un file modello creato manualmente in Microsoft Excel 2007.

Il seguente esempio carica un file modello XLSX, definisce i colori per diversi tipi di colore del tema, applica i colori personalizzati e salva il file Excel.

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"));

Come applicare colori tema in Aspose.Cells

Il seguente esempio applica i colori di primo piano e di carattere di una cella in base ai tipi di colore predefiniti del tema (del workbook). Salva anche il file Excel su disco.

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"));

Come ottenere e impostare colori tema in Aspose.Cells

Di seguito sono riportati alcuni metodi e proprietà che implementano i colori tema.

L’esempio seguente mostra come ottenere e impostare i colori del tema.

Il seguente esempio utilizza un file modello XLSX, ottiene i colori per diversi tipi di colore del tema, modifica i colori e salva il file Microsoft Excel.

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"));

Argomenti avanzati