セルのHTML文字列を管理する

可能な使用シナリオ

スタイル付きデータを特定のセルに設定する際は、HTML文字列をセルに割り当てることができます。もちろん、セルのHTML文字列を取得することも可能です。Aspose.Cells for Node.js via C++はこの機能を提供しています。Aspose.Cellsは、目的を達成するための各種プロパティやメソッドを提供しています。

Aspose.Cells for Node.js via C++を使ったHTML文字列の取得と設定

この例では、次のことができます:

  1. ワークブックを作成し、いくつかのデータを追加します。
  2. 最初のワークシートの特定セルを取得します。
  3. HTML文字列をセルに設定します。
  4. セルのHTML文字列を取得します。
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());

サンプルコードによって生成された出力

上記のサンプルコードの出力を以下のスクリーンショットで示します。

todo:image_alt_text