Node.jsをC++経由で使用し、ワークシートで値の代わりに数式を表示する方法についての解説記事
Contents
[
Hide
]
Microsoft Excelでは、数式の表示オプションをリボンの数式タブから選択することで、計算結果ではなく数式を表示できます。数式を表示している場合、Excelはワークシートに数式を表示します。これと同じことを行うにはAspose.Cells for Node.js via C++の方法を使用します。
Aspose.CellsはWorksheet.getShowFormulas()プロパティを提供しています。これをtrueに設定すると、Microsoft Excelに数式を表示させることができます。
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "source.xlsx");
// Load the source workbook
const workbook = new AsposeCells.Workbook(filePath);
// Access the first worksheet
const worksheet = workbook.getWorksheets().get(0);
// Show formulas of the worksheet
worksheet.setShowFormulas(true);
// Save the workbook
workbook.save(path.join(dataDir, ".out.xlsx"));