Show Formulas instead of Values in a Worksheet
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
// 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"); |