Skip to content

Instantly share code, notes, and snippets.

How to Remove Formula in Excel using Python. For more details: https://kb.aspose.com/cells/python/how-to-remove-formula-in-excel-using-python/
import jpype
import asposecells
jpype.startJVM()
from asposecells.api import License, Workbook
# Instantiate the license
license = License()
license.setLicense("Aspose.Total.lic")
# Load the workbook
wb = Workbook("SampleExcelWithFormula.xlsx")
# Get formula cell reference
cell = wb.getWorksheets().get(0).getCells().get("C1")
# Store the value temporarily
data = cell.getValue()
# Remove the formula
cell.setFormula("")
# Save the value back
cell.setValue(data)
# Save the workbook
wb.save("WorkbookWithDataOnly.xlsx")
print("Formula removed")
jpype.shutdownJVM()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment