コード例 #1
0
def gnm_init():
    global cc
    global ioc

    # Initialize Gnm itself
    Gnm.init()

    # create a stderr reporting context
    cc = Gnm.CmdContextStderr.new()

    # Load plugins
    Gnm.plugins_init(cc)

    # A context for io operations
    ioc = GOffice.IOContext.new(cc)

    return ()
コード例 #2
0
#!/usr/bin/python
# -----------------------------------------------------------------------------

import gi
gi.require_version('Gnm', '1.12')
from gi.repository import Gnm
Gnm.init()

# A context for reporting errors to stderr
cc = Gnm.CmdContextStderr.new()

# Load plugins
Gnm.plugins_init(cc)

# -----------------------------------------------------------------------------

# Create a workbook with one sheet
wb = Gnm.Workbook.new_with_sheets(1)

# Get sheet.  Index starts at 0
sheet = wb.sheet_by_index(0)
print("Name: {}".format(sheet.props.name))
print("Number of columns: {}".format (sheet.props.columns))
print("Number of rows: {}".format (sheet.props.rows))

# Store values and expressions is some cells.  Coordinates are (col,row)
# both starting at 0.  (So what the gui sees as row 1 is 0 here.)
sheet.cell_set_value(0,0,Gnm.Value.new_int(10))
sheet.cell_set_value(0,1,Gnm.Value.new_float(101.25))
sheet.cell_set_text(0,2,"=A1+A2")
sheet.cell_set_text(0,3,"'01")
コード例 #3
0
ファイル: gnumeric.py プロジェクト: markus61/iac-protocol
"""
Gnumeric interface for the IAC protocol

Requirements:  
    - Install gnumeric
    - Enable the "Python plugin loader" by going to Tools > Plug-ins... -> Plugin List 
      and selecting it from the checkbox list.
"""
from gi.repository import GOffice
from gi.repository import Gnm
import warnings


with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    Gnm.init()


class CellRangeCalculator(object):
    def column_index(self, column):
        if len(column) == 1:
            column_list = list(column[0])
        else:
            column_list = column
        base26 = []
        for i in range(len(column_list)):
            if column_list[i].isdigit():
                return False
            else:
                base26.append(ord(column_list[i].lower()) - ord("a") + 1)
        return base26