UPDATE: Python bindings for the user API

This commit is contained in:
Nicolás Hatcher
2025-06-07 15:37:22 +02:00
committed by Nicolás Hatcher Andrés
parent faa0ff9b69
commit 07854f1593
12 changed files with 247 additions and 34 deletions

View File

@@ -8,7 +8,8 @@ IronCalc
installation
usage_examples
top_level_methods
api_reference
raw_api_reference
user_api_reference
objects
IronCalc is a spreadsheet engine that allows you to create, modify and save spreadsheets.

View File

@@ -1,6 +1,6 @@
API Reference
-------------
Raw API Reference
-----------------
In general methods in IronCalc use a 0-index base for the the sheet index and 1-index base for the row and column indexes.
@@ -28,7 +28,7 @@ In general methods in IronCalc use a 0-index base for the the sheet index and 1-
.. method:: get_cell_content(sheet: int, row: int, column: int) -> str
Returns the raw content of a cell. If the cell contains a formula,
Returns the raw content of a cell. If the cell contains a formula,
the returned string starts with ``"="``.
:param sheet: The sheet index (0-based).
@@ -47,7 +47,7 @@ In general methods in IronCalc use a 0-index base for the the sheet index and 1-
.. method:: get_formatted_cell_value(sheet: int, row: int, column: int) -> str
Returns the cells value as a formatted string, taking into
Returns the cells value as a formatted string, taking into
account any number/currency/date formatting.
:param sheet: The sheet index (0-based).
@@ -167,7 +167,7 @@ In general methods in IronCalc use a 0-index base for the the sheet index and 1-
.. method:: get_worksheets_properties() -> List[PySheetProperty]
Returns a list of :class:`PySheetProperty` describing each worksheets
Returns a list of :class:`PySheetProperty` describing each worksheets
name, visibility state, ID, and tab color.
:rtype: list of PySheetProperty
@@ -204,7 +204,7 @@ In general methods in IronCalc use a 0-index base for the the sheet index and 1-
.. method:: test_panic()
A test method that deliberately panics in Rust.
A test method that deliberately panics in Rust.
Used for testing panic handling at the method level.
:raises WorkbookError: (wrapped Rust panic)

View File

@@ -1,6 +1,13 @@
Top Level Methods
-----------------
This module provides a set of top-level methods for creating and loading IronCalc models.
.. autofunction:: ironcalc.create
.. autofunction:: ironcalc.load_from_xlsx
.. autofunction:: ironcalc.load_from_icalc
.. autofunction:: ironcalc.load_from_icalc
.. autofunction:: ironcalc.load_from_bytes
.. autofunction:: ironcalc.create_user_model
.. autofunction:: ironcalc.create_user_model_from_bytes
.. autofunction:: ironcalc.create_user_model_from_xlsx
.. autofunction:: ironcalc.create_user_model_from_icalc

View File

@@ -0,0 +1,41 @@
User API Reference
------------------
This is the "user api". Models here have history, they evaluate automatically with each change and have a "diff" history.
.. method:: save_to_xlsx(file: str)
Saves the user model to file in the XLSX format.
::param file: The file path to save the model to.
.. method:: save_to_icalc(file: str)
Saves the user model to file in the internal binary ic format.
::param file: The file path to save the model to.
.. method:: apply_external_diffs(external_diffs: bytes)
Applies external diffs to the model. This is used to apply changes from other instances of the model.
::param external_diffs: The external diffs to apply, as a byte array.
.. method:: flush_send_queue() -> bytes
Flushes the send queue and returns the bytes to be sent to the client. This is used to send changes to the client.
.. method:: set_user_input(sheet: int, row: int, column: int, value: str)
Sets an input in a cell, as would be done by a user typing into a spreadsheet cell.
.. method:: get_formatted_cell_value(sheet: int, row: int, column: int) -> str
Returns the cells value as a formatted string, taking into account any number/currency/date formatting.
.. method:: to_bytes() -> bytes
Returns the model as a byte array. This is useful for sending the model over a network or saving it to a file.