Gestisci Stringa Html Celle

Possibili Scenari di Utilizzo

Quando hai bisogno di impostare dati stilizzati per una cella specifica, puoi assegnare una stringa HTML alla cella. Ovviamente, puoi anche ottenere la stringa HTML della cella. Aspose.Cells for Node.js via C++ offre questa funzione. Aspose.Cells fornisce le seguenti proprietà e metodi per aiutarti a raggiungere i tuoi obiettivi.

Ottieni e imposta la stringa HTML usando Aspose.Cells for Node.js via C++

Questo esempio mostra come:

  1. Creare un workbook e aggiungere alcuni dati.
  2. Ottieni la cella specifica nel primo foglio di lavoro.
  3. Imposta la stringa HTML nella cella.
  4. Ottieni la stringa HTML della cella.
const AsposeCells = require("aspose.cells.node");
const path = require("path");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
// Instantiating a Workbook object
let workbook = new AsposeCells.Workbook();
// Obtaining the reference of the newly added worksheet
let ws = workbook.getWorksheets().get(0);
let cells = ws.getCells();
// Setting the value to the cells
let cell = cells.get("A1");
cell.putValue("Fruit");
cell = cells.get("B1");
cell.putValue("Count");
cell = cells.get("C1");
cell.putValue("Price");
cell = cells.get("A2");
cell.putValue("Apple");
cell = cells.get("A3");
cell.putValue("Mango");
cell = cells.get("A4");
cell.putValue("Blackberry");
cell = cells.get("A5");
cell.putValue("Cherry");
let c3 = cells.get("C3");
// set html string for C3 cell.
c3.setHtmlString("<b>test bold</b>");
let c4 = cells.get("C4");
// set html string for C4 cell.
c4.setHtmlString("<i>test italic</i>");
// get the html string of specific cell.
console.log(c3.getHtmlString());
console.log(c4.getHtmlString());

Output generato dal codice di esempio

Lo screenshot seguente mostra l’output del codice di esempio precedente.

todo:image_alt_text