Hi there, I added a python script with =py(…) in Excel. I loaded the file with aspose.cells, but when accessing the cell A1 and reading the formula (with c.formula) I only get “=_xlws.PY(0,1)”. I would like to have the script though between PY( and ). Where can i find it?
Aspose.Cells can read the text of the formula that is stored in the cell, but it does not retrieve the Python code that Excel keeps for the PY() function.
When Excel saves a cell that contains a Python script, the workbook only stores a placeholder such as
=_xlws.PY(0,1)
The actual script (print('Hello Python in Excel')) is kept by Excel’s Python‑in‑Excel feature (it lives in a hidden part of the workbook that is not exposed via the standard Open XML parts). Aspose.Cells does not parse or expose that hidden data, so the library will always return the placeholder string when you read cell.Formula.
What can be done?
Goal
Possibility with Aspose.Cells
Alternative
Read the exact Python code
Not supported – only the placeholder is returned.
Use Microsoft Excel (or Office Scripts API) to extract the script, then process it separately.
Read any normal Excel formula
Fully supported – cell.Formula returns the exact text.
–
Write a Python script into a cell
You can set the placeholder (cell.Formula = "=_xlws.PY(0,1)"), but the real script will not be stored.
Use Excel’s UI or Office Add‑in that inserts the script.
Recommended approach
If you only need the placeholder – continue using cell.Formula.
If you need the actual script – you will have to extract it with Excel itself (e.g., using Office Scripts, the Excel JavaScript API, or the Excel Interop libraries) before handing the file to Aspose.Cells.
If you want to embed custom logic – consider using Aspose.Cells custom functions (C#, VB.NET, etc.) or evaluating the formula server‑side with Aspose.Cells’ calculation engine.
@norman.neubert
The feature is not supported now.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-59382
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
I noticed another thing / bug which is important, too:
Wenn I load an Excel file with python in it into Aspose.cells and save the file again, the python part is gone! In the xlsx the corresponding xml section is missing after save. This is quite severe as the formulas with python don’t work anymore.
@norman.neubert
Which version of Aspose.Cells are you using? Please try the latest version 25.11.
If you still has problems , please share your template file here, we will check it ASAP.
@norman.neubert
Thank you for your feedback. Please take your time to try the latest version 25.11. Hopefully, your issue will be sorted out. Please let us know your feedback.