在工作表中显示公式而不是值

Contents
[ ]

Aspose.Cells提供了工作表.setShowFormulas()财产。将此设置为真的设置Microsoft Excel显示公式。

下图显示了在单元格 A3 中具有公式的工作表:=Sum(A1:A2)。

单元格 A3 中包含公式的工作表

待办事项:图片_替代_文本

下图显示了公式而不是计算值,通过设置启用工作表.setShowFormulas()财产给真的与 Aspose.Cells。

工作表现在显示公式而不是计算值

待办事项:图片_替代_文本

// 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");