Réutilisation d objets de style

Contents
[ ]

Pour appliquer une mise en forme à une grande plage de cellules dans une feuille de calcul :

  1. Créer un objet de style.
  2. Spécifier les attributs.
  3. Appliquer le style aux cellules dans la plage.
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
// Create workbook object
const workbook = new AsposeCells.Workbook();
// Access the first worksheet
const worksheet = workbook.getWorksheets().get(0);
// Access cells
const cell1 = worksheet.getCells().get("A1");
const cell2 = worksheet.getCells().get("B1");
// Set the styles of both cells to Times New Roman
const styleObject = workbook.createStyle();
styleObject.getFont().setColor(AsposeCells.Color.Red);
styleObject.getFont().setName("Times New Roman");
cell1.setStyle(styleObject);
cell2.setStyle(styleObject);
// Put the values inside the cell
cell1.putValue("Hello World!");
cell2.putValue("Hello World!!");
// Save to Pdf without setting PdfSaveOptions.IsFontSubstitutionCharGranularity
workbook.save(path.join(dataDir, "SampleOutput_out.xlsx"));