ワークシートで値ではなく数式を表示する
Contents
[
Hide
]
Microsoft Excelでは、数式リボンの数式を表示オプションを使用して、計算された値の代わりに数式を表示することができます。数式が表示されると、Microsoft Excelはワークシートに数式を表示します。Aspose.Cellsを使用して同じことを実現することができます。
Aspose.Cellsは**Worksheet.setShowFormulas()**プロパティを提供します。これを**true**に設定すると、Microsoft Excelが数式を表示するようになります。
次の画像は、セルA3に数式=Sum(A1:A2)があるワークシートを示しています。
セルA3に数式があるワークシート
次の画像は、Aspose.Cellsを使用して**Worksheet.setShowFormulas()**プロパティを**true**に設定することで、計算された値の代わりに数式を表示しているワークシートを示しています。
ワークシートには、計算値の代わりに数式が表示されています
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ShowFormulas.class); | |
// Load the source workbook | |
Workbook workbook = new Workbook(dataDir + "source.xlsx"); | |
// Access the first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Show formulas of the worksheet | |
worksheet.setShowFormulas(true); | |
// Save the workbook | |
workbook.save(dataDir + "out.xlsx"); |