A cell with Pythong only shows =_xlws.PY(0,1) when accessed via c.formula. Where is the script?

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?

My formula for example is:

=PY(print(‘Hello Python in Excel’))

Thanks in advance.

@norman.neubert

Answer

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

  1. If you only need the placeholder – continue using cell.Formula.
  2. 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.
  3. 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.

References


If you have any further questions about how to work with formulas, custom functions, or other Aspose.Cells features, feel free to ask!

@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.

Thanks Simon, thats great! :slight_smile: Looking forward to this feature!

Kind regards
Norman

@norman.neubert
You are welcome! But I have to say we only can try to return scripts , we can not support to run these Python codes.

That would just be perfect for me as I only have to read it, not execute it. That would be very very cool :slight_smile:

@norman.neubert
Alright, we will start this work as soon as possible.