This page provides a guide on how to setup and use Gnumeric for the IAC protocol.
Warning
Gnumeric needs to have the Python plugin loader enabled for it to function properly. Please see the instructions for more details.
If you wish to contribute to improving Gnumeric’s functionality, view the Gnumeric plugin documentation for Python or discover it’s properties using Python’s object introspection on Gnumeric’s module gi.repository.
Then, clone the project repository from the project’s GitHub page, add your modified application, and submit a pull request to be reviewed. If your additions to the application follow the protocol convention and it doesn’t contain any obvious errors, it will be accepted! See IAC protocol plugin implementation for more details.
Here is an example Hello, World! shell script. Run the server (iacs) and try this script:
#!/usr/bin/env bash
# Netcat: -u is for UDP, -c closes the connection on EOF
PORT=14733
if [[ $# -eq 3 ]]; then
echo -e "gnumeric -> doc = new_document(1)\n" | nc -uc localhost $PORT
echo -e "gnumeric -> sheet = doc.get_sheet(0)\n" | nc -uc localhost $PORT
echo -e "gnumeric -> cell = sheet.fetch_cell('$1')\n" | nc -uc localhost $PORT
echo -e "gnumeric -> cell.set_text('$2')\n" | nc -uc localhost $PORT
echo -e "gnumeric -> doc.save_as('$3')\n" | nc -uc localhost $PORT
else
echo "Usage: $0 [cell] [string] [path]"
fi
Or try the interpreter by directing the following as stdin:
gnumeric -> doc = new_document(1)
gnumeric -> sheet = doc.get_sheet(0)
gnumeric -> cell = sheet.fetch_cell('A1')
gnumeric -> cell.set_text('Hello, World!')
gnumeric -> doc.save_as('./hello.gnumeric')
And then run it as something like iaci < hello-gnumeric.txt (assuming it’s saved as that name).
gnumeric -> doc = new_document(1)
Parameters: | number_of_sheets (int) – The number of sheets to create in the document. |
---|---|
Returns: | A workbook object. |
Noindex: |
gnumeric -> sheet = doc.get_sheet(0)
Parameters: | sheet_index (int) – The index of the sheet to access. |
---|---|
Returns: | A sheet object. |
Noindex: |
gnumeric -> cell = sheet.fetch_cell(‘A1’)
Parameters: | cell_range (str) – The cell to be fetched. |
---|---|
Returns: | A cell object. |
Noindex: |
gnumeric -> cell.set_text(“Hello, World!”)
Parameters: | string (str) – A string to set the cell contents to. |
---|---|
Returns: | True on success, False otherwise. |
Noindex: |
gnumeric -> cell.get_text()
Returns: | The cell’s text. |
---|---|
Noindex: |
gnumeric -> doc.save_as(‘/home/gyeh/hello.gnumeric’)
Parameters: | path (str) – The path to save the workbook to (must end with .gnumeric) |
---|---|
Returns: | True on success, False otherwise. |
Noindex: |