Show Formulas instead of Values in a Worksheet
Contents
[
Hide
]
It is possible to show formulas instead of calculated values in Microsoft Excel using tShow Formulas option from the Formulas ribbon. When formulas are shown, Microsoft Excel displays formulas in the worksheet. You can achieve the same thing using Aspose.Cells.
Aspose.Cells provides a Worksheet.setShowFormulas() property. Set this to true to set Microsoft Excel to display formulas.
The following image shows the worksheet which has a formula in cell A3: =Sum(A1:A2).
Worksheet with formula in cell A3
The following image shows the formula instead of the calculated value, enabled by setting the Worksheet.setShowFormulas() property to true with Aspose.Cells.
Worksheet now shows formula instead of the calculated value
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"); |