在工作表中显示公式而不是值
Contents
[
Hide
]
可以使用 t 在 Microsoft Excel 中显示公式而不是计算值显示公式选项从公式丝带。显示公式时,Microsoft Excel 在工作表中显示公式。您可以使用 Aspose.Cells 实现相同的目的。
Aspose.Cells提供了工作表.setShowFormulas()财产。将此设置为真的设置Microsoft Excel显示公式。
下图显示了在单元格 A3 中具有公式的工作表:=Sum(A1:A2)。
单元格 A3 中包含公式的工作表
下图显示了公式而不是计算值,通过设置启用工作表.setShowFormulas()财产给真的与 Aspose.Cells。
工作表现在显示公式而不是计算值
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"); |