pub struct PyCode {
pub code: String,
pub object: bool,
pub output: Option<PyOutput>,
pub stale: bool,
}Expand description
A Python cell.
Fields§
§code: String§object: boolShow the result as a Python object (true) or convert it to cell values (false).
output: Option<PyOutput>The last result, when the code ran without an error.
stale: boolThe cell’s inputs changed while calculation was manual: its value is out of date until the workbook is calculated.
Implementations§
Source§impl PyCode
impl PyCode
pub fn new(code: &str) -> PyCode
Sourcepub fn result_value(&self) -> Option<Value>
pub fn result_value(&self) -> Option<Value>
What the cell shows for its result: cell values (an array spills from the cell), or, for a
Python object, its type name. None before the code has run.
Sourcepub fn to_formula(&self) -> String
pub fn to_formula(&self) -> String
The cell as a formula (without =): PY("…"&"…",0), with the code in string literals of
at most 255 characters and the return type Excel documents: 0 for an Excel value, 1 for a
Python object.
Sourcepub fn to_file_formula(&self) -> String
pub fn to_file_formula(&self) -> String
PyCode::to_formula with Excel’s _xlfn._xlws. prefix: the string-literal form
PyCode::from_formula reads from files that hold it, and what the size limit measures.
An xlsx file names the code by index instead ([MS-XLSX] 2.3.10.2).
Sourcepub fn fits(&self) -> bool
pub fn fits(&self) -> bool
Whether the code fits in a PY formula of at most MAX_FORMULA_CHARS characters.
Sourcepub fn from_formula(text: &str) -> Option<PyCode>
pub fn from_formula(text: &str) -> Option<PyCode>
Reads a PY(…) formula (with or without =, and with or without the _xlfn. and
_xlws. prefixes): string literals joined by &, optionally followed by ,0 or ,1.
None for anything else.