Last active
July 16, 2023 16:57
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/
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
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