Node.jsとC++を使用してチャートのワークシートを取得する

Contents
[ ]

以下の例は Chart.getWorksheet() プロパティの使用例を示します。最初にワークシートの名前を出力し、その後最初のチャートにアクセスします。再びワークシート名を出力し、Chart.getWorksheet() プロパティを使用します。

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");

// Loads the workbook which contains hidden external links
const workbook = new AsposeCells.Workbook(path.join(dataDir, "sample.xlsx"));

// Access first worksheet of the workbook
const worksheet = workbook.getWorksheets().get(0);

// Print worksheet name
console.log("Sheet Name: " + worksheet.getName());

// Access the first chart inside this worksheet
const charts = worksheet.getCharts();
if (charts.getCount() > 0) {
const chart = charts.get(0);

// Access the chart's sheet and display its name again
console.log("Chart's Sheet Name: " + chart.getWorksheet().getName());
} else {
console.log("No charts available in the worksheet.");
}

以下はサンプルコードのコンソール出力です。同じワークシート名が2回印刷されることがわかります。

Sheet Name: Portfolio

Chart's Sheet Name: Portfolio