Utilizzo di stili incorporati con C++

Come utilizzare gli stili incorporati

Il metodo Workbook.CreateBuiltinStyle e l’enumerazione BuiltinStyleType rendono comodo l’uso degli stili incorporati. Ecco un elenco di tutti gli stili incorporati possibili:

  • TWENTY_PERCENT_ACCENT_1
  • TWENTY_PERCENT_ACCENT_2
  • TWENTY_PERCENT_ACCENT_3
  • TWENTY_PERCENT_ACCENT_4
  • TWENTY_PERCENT_ACCENT_5
  • VENTI_PERC_ACCENTO_6
  • QUARANTA_PERC_ACCENTO_1
  • QUARANTA_PERC_ACCENTO_2
  • QUARANTA_PERC_ACCENTO_3
  • QUARANTA_PERC_ACCENTO_4
  • QUARANTA_PERC_ACCENTO_5
  • QUARANTA_PERC_ACCENTO_6
  • SESSANTA_PERC_ACCENTO_1
  • SESSANTA_PERC_ACCENTO_2
  • SESSANTA_PERC_ACCENTO_3
  • SESSANTA_PERC_ACCENTO_4
  • SESSANTA_PERC_ACCENTO_5
  • SESSANTA_PERC_ACCENTO_6
  • ACCENTO_1
  • ACCENTO_2
  • ACCENTO_3
  • ACCENTO_4
  • ACCENTO_5
  • ACCENTO_6
  • CATTIVO
  • CALCOLO
  • CONTROLLA_CELLA
  • VIRGOLA
  • VIRGOLA_1
  • VALUTA
  • VALUTA_1
  • TESTO_ESPLICATIVO
  • BUONO
  • INTESTAZIONE_1
  • INTESTAZIONE_2
  • INTESTAZIONE_3
  • INTESTAZIONE_4
  • HYPERLINK
  • COLLEGAMENTO_IPERTESTO_SEGUITO
  • INPUT
  • CELLA_COLLEGATA
  • NEUTRO
  • NORMALE
  • NOTA
  • OUTPUT
  • PERCENTUALE
  • TITOLO
  • TOTALE
  • TESTO_AVVISO
  • LIVELLO_RIGA
  • LIVELLO_COLONNA

Codice C++ per usare gli stili incorporati

#include <iostream>
#include "Aspose.Cells.h"

using namespace Aspose::Cells;

int main()
{
    Aspose::Cells::Startup();

    // Source directory path
    U16String srcDir(u"..\\Data\\01_SourceDirectory\\");

    // Output file paths
    U16String output1Path = srcDir + u"Output.xlsx";
    U16String output2Path = srcDir + u"Output.out.ods";

    // Create a new workbook
    Workbook workbook;

    // Create a built-in style of type Title
    Style style = workbook.CreateBuiltinStyle(BuiltinStyleType::Title);

    // Get the first worksheet and its cells
    Worksheet worksheet = workbook.GetWorksheets().Get(0);
    Cells cells = worksheet.GetCells();

    // Access cell A1 and set its value and style
    Cell cell = cells.Get(u"A1");
    cell.PutValue(u"Aspose");
    cell.SetStyle(style);

    // Auto-fit the first column and row
    worksheet.AutoFitColumn(0);
    worksheet.AutoFitRow(0);

    // Save the workbook to the first output path
    workbook.Save(output1Path);
    std::cout << "File saved " << output1Path.ToUtf8() << std::endl;

    // Save the workbook to the second output path
    workbook.Save(output2Path);
    std::cout << "File saved " << output2Path.ToUtf8() << std::endl;

    Aspose::Cells::Cleanup();
    return 0;
}