Riutilizzo degli oggetti stile

Contents
[ ]

Per applicare una formattazione a un’ampia gamma di celle in un foglio di lavoro:

  1. Creare un oggetto stile.
  2. Specificare gli attributi.
  3. Applicare lo stile alle celle nell’intervallo.
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"));