Pro.SiliconSpreadsheet — Spreadsheet macro emulation API

Overview

The Pro.SiliconSpreadsheet module contains the core API for emulating Microsoft Excel macros.

Although this module provides a complete format-agnostic environment for emulating macros, most use-cases will revolve around extending the emulator.

Core Concepts

The most important classes are:

Extending the Excel Macro Emulator

The Excel emulator doesn’t provide an implementation for every available function. In certain cases it is necessary to extend the emulator to proceed with the analysis of a malicious document.

Extending the Excel macro emulator is a simple operation. The following code sample provides the implementation for the NOW function, returning a fixed value.

from Pro.SiliconSpreadsheet import *
from Pro.UI import proContext

class EmulatorHelper(SiliconExcelEmulatorHelper):

    def __init__(self):
        super(EmulatorHelper, self).__init__()

    def evaluateFunction(self, emu, ctx, opts, depth, e):
        function_name = e.toString()
        # implements the NOW function returning a fixed value
        if function_name == "NOW":
            return SiliconExcelEmulatorValue(SiliconSpreadsheetValueType_Number, "44249.708602")
        return SiliconExcelEmulatorValue()

# retrieves the current analysis view
v = proContext().getCurrentAnalysisView()
if v.isValid():
    view = SiliconSpreadsheetWorkspaceView(v)
    # sets the emulator helper
    helper = EmulatorHelper()
    emu = view.getExcelEmulator()
    emu.setHelper(helper)
else:
    print("error: couldn't find view")

This type of extension might be needed to decrypt cell values.

Replacing Cell Values

In some cases malicious documents contain obfuscated cell values or formulas.

The following code sample shows how to replace cell formulas programmatically.

from Pro.SiliconSpreadsheet import *
from Pro.UI import proContext
import re

# retrieves the current analysis view
v = proContext().getCurrentAnalysisView()
if v.isValid():
    view = SiliconSpreadsheetWorkspaceView(v)
    # retrieves the spreadsheet workspace
    ws = view.getSpreadsheetWorkspace()
    # iterates through the sheets
    sheets = ws.getSheets()
    nchanged = 0
    for i in range(sheets.size()):
        sheet = ws.getSheet(i)
        it = sheet.cellIterator()
        while it.hasNext():
            ci = it.next()
            formula = ci.cell.formula
            # the following regular expression removes sheet name prefixes
            # E.g.: 'SHEET'!A1 -> A1
            #formula = re.sub("[']?[^']*['][!]", "", formula)
            # the following regular expression removes simple ATAN() formulas
            # E.g.: =ATAN(100000)=HALT()=ATAN(230000) -> =HALT()
            #formula = re.sub("[=]?ATAN[(][^)]*[)]", "", formula)
            if formula != ci.cell.formula:
                nchanged += 1
                ci.cell.formula = formula
                sheet.addCell(ci.index.column, ci.index.row, ci.cell.value_type, ci.cell.value, ci.cell.formula)
    if nchanged != 0:
        view.refreshSpreadsheets()
        print("info: %d formula were modified" % (nchanged,))
    else:
        print("info: no formula was modified")
else:
    print("error: couldn't find view")

Module API

Pro.SiliconSpreadsheet module API.

Attributes:

SI_EXCEL_TOKEN_AND

Excel macro lexical token type.

SI_EXCEL_TOKEN_BOOLEAN

Excel macro lexical token type.

SI_EXCEL_TOKEN_CELL

Excel macro lexical token type.

SI_EXCEL_TOKEN_CELL_RANGE

Excel macro lexical token type.

SI_EXCEL_TOKEN_CLOSEP

Excel macro lexical token type.

SI_EXCEL_TOKEN_CLOSE_CURLY

Excel macro lexical token type.

SI_EXCEL_TOKEN_COMMA

Excel macro lexical token type.

SI_EXCEL_TOKEN_DIVIDE

Excel macro lexical token type.

SI_EXCEL_TOKEN_EQUAL

Excel macro lexical token type.

SI_EXCEL_TOKEN_ERROR

Excel macro lexical token type.

SI_EXCEL_TOKEN_GREATER

Excel macro lexical token type.

SI_EXCEL_TOKEN_GREATER_OR_EQUAL

Excel macro lexical token type.

SI_EXCEL_TOKEN_LESS

Excel macro lexical token type.

SI_EXCEL_TOKEN_LESS_OR_EQUAL

Excel macro lexical token type.

SI_EXCEL_TOKEN_MINUS

Excel macro lexical token type.

SI_EXCEL_TOKEN_NAME

Excel macro lexical token type.

SI_EXCEL_TOKEN_NOT_EQUAL

Excel macro lexical token type.

SI_EXCEL_TOKEN_NULL

Excel macro lexical token type.

SI_EXCEL_TOKEN_NUMBER

Excel macro lexical token type.

SI_EXCEL_TOKEN_OPENP

Excel macro lexical token type.

SI_EXCEL_TOKEN_OPEN_CURLY

Excel macro lexical token type.

SI_EXCEL_TOKEN_PLUS

Excel macro lexical token type.

SI_EXCEL_TOKEN_POW

Excel macro lexical token type.

SI_EXCEL_TOKEN_STRING

Excel macro lexical token type.

SI_EXCEL_TOKEN_TIMES

Excel macro lexical token type.

SI_EXCEL_TOKEN_UNARY_MINUS

Excel macro lexical token type.

SI_EXCEL_TOKEN_UNARY_PLUS

Excel macro lexical token type.

SiliconSpreadsheetValueType_Array

Spreadsheet array value type.

SiliconSpreadsheetValueType_Boolean

Spreadsheet boolean value type.

SiliconSpreadsheetValueType_Cell

Spreadsheet cell reference value type.

SiliconSpreadsheetValueType_CellRange

Spreadsheet cell range reference value type.

SiliconSpreadsheetValueType_Error

Spreadsheet error value type.

SiliconSpreadsheetValueType_Null

Spreadsheet null value type.

SiliconSpreadsheetValueType_Number

Spreadsheet number value type.

SiliconSpreadsheetValueType_String

Spreadsheet string value type.

SiliconSpreadsheetValueType_ToEvaluate

Spreadsheet minimum value type to evaluate.

SiliconSpreadsheetValueType_Unknown

Spreadsheet unknown value type.

Classes:

SiliconExcelEmulator()

This class represents the Excel macro emulator.

SiliconExcelEmulatorCtx()

This class represents an Excel macro emulator context containing the formula being evaluated and its associated spreadsheet index, which is needed to resolve relative cell names.

SiliconExcelEmulatorHelper()

This class can be used to extend the Excel macro emulator.

SiliconExcelEmulatorValue()

This class represents an Excel emulator value.

SiliconExcelEmulatorValueList()

List of SiliconExcelEmulatorValue elements.

SiliconExcelEmulatorValueListIt(obj)

Iterator class for SiliconExcelEmulatorValueList.

SiliconExcelExpr()

This class represents a parsed Excel macro expression as AST.

SiliconExcelExprList()

List of SiliconExcelExpr elements.

SiliconExcelExprListIt(obj)

Iterator class for SiliconExcelExprList.

SiliconSpreadsheetCell()

This class represents a spreadsheet cell value.

SiliconSpreadsheetCellIndex()

This class represents a spreadsheet cell index and its value.

SiliconSpreadsheetCellIterator(sheet_or_ws, …)

An iterator for the cells in a workspace or in a single spreadsheet.

SiliconSpreadsheetIndex()

This class represents a spreadsheet index.

SiliconSpreadsheetRange()

This class represents a spreadsheet index range.

SiliconSpreadsheetSheet(name)

This class represents an individual spreadsheet sheet.

SiliconSpreadsheetSheetList()

List of SiliconSpreadsheetSheet elements.

SiliconSpreadsheetSheetListIt(obj)

Iterator class for SiliconSpreadsheetSheetList.

SiliconSpreadsheetUtil()

This class contains static methods to convert spreadsheet indexes to and from strings.

SiliconSpreadsheetValue()

This class represents a spreadsheet value.

SiliconSpreadsheetWorkspace()

This class represents a spreadsheet workspace (i.e., a collection of sheets).

SiliconSpreadsheetWorkspaceView(view)

This class is used to interact with the view used to display a spreadsheet workspace.

Functions:

siliconCreateSpreadsheetWorkspaceView(sdata, w)

Creates a spreadsheet workspace view.

SI_EXCEL_TOKEN_AND: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_BOOLEAN: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_CELL: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_CELL_RANGE: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_CLOSEP: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_CLOSE_CURLY: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_COMMA: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_DIVIDE: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_EQUAL: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_ERROR: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_GREATER: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_GREATER_OR_EQUAL: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_LESS: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_LESS_OR_EQUAL: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_MINUS: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_NAME: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_NOT_EQUAL: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_NULL: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_NUMBER: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_OPENP: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_OPEN_CURLY: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_PLUS: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_POW: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_STRING: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_TIMES: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_UNARY_MINUS: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

SI_EXCEL_TOKEN_UNARY_PLUS: Final[int]

Excel macro lexical token type.

See also SiliconExcelExpr.type.

class SiliconExcelEmulator

This class represents the Excel macro emulator.

See also SiliconExcelEmulatorHelper.

Attributes:

EmulatorOpt_EvalReferences

Evaluate references option for the emulation.

EmulatorOpt_None

No options value for the emulation.

Methods:

argCount(e)

Returns the number of arguments for an expression.

argToValue(ctx, opts, depth, e, i)

Converts an expression argument into an emulator value.

argsToValueList(ctx, opts, depth, e)

Converts the arguments of an expression into an emulator value list.

evaluate(formula[, idx, opts, depth])

Evaluates an Excel formula.

evaluateStandardFunction(ctx, opts, depth, e)

Evaluate a built-in function.

evaluateToString(formula[, idx])

Evaluates an Excel formula and converts the result to a string.

expectedArguments(e, min_args[, max_args])

Checks the number of arguments for an expression.

exprToValue(ctx, opts, depth, e)

Converts an expression into an emulator value.

getHelper()

Returns the emulator helper if available; otherwise returns None.

getMaxCallStackDepth()

Returns the maximum evaluation depth.

getWait()

Returns the emulator wait object if available; otherwise returns None.

getWorkspace()

Returns the spreadsheet workspace.

isVerbose()

Returns True if verbose output is enabled; otherwise returns False.

setHelper(helper)

Sets the emulator helper.

setMaxCallStackDepth(depth)

Sets the maximum evaluation depth.

setVerbose(b)

Sets the status of verbose output.

setWait(wait)

Sets the emulator wait object.

setWorkspace(w)

Sets the spreadsheet workspace.

spreadsheetValueToValue(cell)

Converts a spreadsheet cell value into an emulator value.

valueToConcatString(v)

Converts an emulator value into a concatenated string.

valueToSpreadsheetValue(value)

Converts an emulator value into a spreadsheet value.

valueToString(v)

Converts an emulator value to string.

EmulatorOpt_EvalReferences: Final[int]

Evaluate references option for the emulation.

See also evaluate().

EmulatorOpt_None: Final[int]

No options value for the emulation.

See also evaluate().

argCount(e: Pro.SiliconSpreadsheet.SiliconExcelExpr)int

Returns the number of arguments for an expression.

Parameters

e (SiliconExcelExpr) – The expression.

Returns

Returns the number of arguments for the specified expression.

Return type

int

See also argToValue() and argsToValueList().

argToValue(ctx: Pro.SiliconSpreadsheet.SiliconExcelEmulatorCtx, opts: int, depth: int, e: Pro.SiliconSpreadsheet.SiliconExcelExpr, i: int)Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue

Converts an expression argument into an emulator value.

Parameters
Returns

Returns the emulator value if successful; otherwise returns an invalid emulator value.

Return type

SiliconExcelEmulatorValue

See also argCount() and argsToValueList().

argsToValueList(ctx: Pro.SiliconSpreadsheet.SiliconExcelEmulatorCtx, opts: int, depth: int, e: Pro.SiliconSpreadsheet.SiliconExcelExpr)Pro.SiliconSpreadsheet.SiliconExcelEmulatorValueList

Converts the arguments of an expression into an emulator value list.

Parameters
Returns

Returns the emulator value list if successful; otherwise returns an empty emulator value list.

Return type

SiliconExcelEmulatorValueList

See also argCount() and argToValue().

evaluate(formula: str, idx: Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex = SiliconSpreadsheetIndex(), opts: int = EmulatorOpt_EvalReferences, depth: int = 0)Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue

Evaluates an Excel formula.

Parameters
  • formula (str) – The formula to evaluate.

  • idx (SiliconSpreadsheetIndex) – The index associated the formula, which can be used to resolve relative cell references.

  • opts (int) – The emulation options (e.g., EmulatorOpt_EvalReferences()).

  • depth (int) – The current evaluation depth.

Returns

Returns the result of the evaluation if successful; otherwise returns an invalid value.

Return type

SiliconExcelEmulatorValue

See also evaluateToString(), SiliconSpreadsheetIndex and SiliconExcelEmulatorValue.

evaluateStandardFunction(ctx: Pro.SiliconSpreadsheet.SiliconExcelEmulatorCtx, opts: int, depth: int, e: Pro.SiliconSpreadsheet.SiliconExcelExpr)Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue

Evaluate a built-in function.

Parameters
Returns

Returns the result of the evaluation if successful; otherwise returns an invalid value.

Return type

SiliconExcelEmulatorValue

See also evaluate(), SiliconExcelEmulatorCtx, SiliconExcelExpr and SiliconExcelEmulatorValue.

evaluateToString(formula: str, idx: Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex = SiliconSpreadsheetIndex())str

Evaluates an Excel formula and converts the result to a string.

Parameters
  • formula (str) – The formula to evaluate.

  • idx (SiliconSpreadsheetIndex) – The index associated the formula, which can be used to resolve relative cell references.

Returns

Returns the result of the evaluation as string if successful; otherwise returns an empty string.

Return type

str

See also evaluate() and SiliconSpreadsheetIndex.

expectedArguments(e: Pro.SiliconSpreadsheet.SiliconExcelExpr, min_args: int, max_args: int = - 1)bool

Checks the number of arguments for an expression.

Parameters
  • e (SiliconExcelExpr) – The expression to check.

  • min_args (int) – The minimum amount of expected arguments.

  • max_args (int) – The maximum amount of expected arguments.

Returns

Returns True if the expression honors the number of expected arguments; otherwise returns False.

Return type

bool

See also SiliconExcelExpr.

exprToValue(ctx: Pro.SiliconSpreadsheet.SiliconExcelEmulatorCtx, opts: int, depth: int, e: Pro.SiliconSpreadsheet.SiliconExcelExpr)Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue

Converts an expression into an emulator value.

Parameters
Returns

Returns the emulator value if successful; otherwise returns an invalid emulator value.

Return type

SiliconExcelEmulatorValue

See also evaluate(), SiliconExcelEmulatorCtx, SiliconExcelExpr and SiliconExcelEmulatorValue.

getHelper()Pro.SiliconSpreadsheet.SiliconExcelEmulatorHelper
Returns

Returns the emulator helper if available; otherwise returns None.

Return type

SiliconExcelEmulatorHelper

See also setHelper() and SiliconExcelEmulatorHelper.

getMaxCallStackDepth()int
Returns

Returns the maximum evaluation depth.

Return type

int

See also setMaxCallStackDepth().

getWait()Pro.Core.NTIWait
Returns

Returns the emulator wait object if available; otherwise returns None.

Return type

NTIWait

See also setWait() and Pro.Core.NTIWait.

getWorkspace()Pro.SiliconSpreadsheet.SiliconSpreadsheetWorkspace
Returns

Returns the spreadsheet workspace.

Return type

SiliconSpreadsheetWorkspace

See also setWorkspace() and SiliconSpreadsheetWorkspace.

isVerbose()bool
Returns

Returns True if verbose output is enabled; otherwise returns False.

Return type

bool

See also setVerbose().

setHelper(helper: Pro.SiliconSpreadsheet.SiliconExcelEmulatorHelper)None

Sets the emulator helper.

Parameters

helper (SiliconExcelEmulatorHelper) – The emulator helper.

See also getHelper() and SiliconExcelEmulatorHelper.

setMaxCallStackDepth(depth: int)None

Sets the maximum evaluation depth.

Parameters

depth (int) – The maximum evaluation depth.

See also getMaxCallStackDepth().

setVerbose(b: bool)None

Sets the status of verbose output.

Parameters

b (bool) – If True, enables verbose output.

See also isVerbose().

setWait(wait: Pro.Core.NTIWait)None

Sets the emulator wait object.

Parameters

wait (NTIWait) – The wait object.

See also getWait() and Pro.Core.NTIWait.

setWorkspace(w: Pro.SiliconSpreadsheet.SiliconSpreadsheetWorkspace)None

Sets the spreadsheet workspace.

Parameters

w (SiliconSpreadsheetWorkspace) – The spreadsheet workspace.

See also getWorkspace() and SiliconSpreadsheetWorkspace.

spreadsheetValueToValue(cell: Pro.SiliconSpreadsheet.SiliconSpreadsheetCell)Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue

Converts a spreadsheet cell value into an emulator value.

Parameters

cell (SiliconSpreadsheetCell) – The spreadsheet cell value to convert.

Returns

Return an emulator value if successful; otherwise returns an invalid emulator value.

Return type

SiliconExcelEmulatorValue

See also SiliconSpreadsheetCell and SiliconExcelEmulatorValue.

valueToConcatString(v: Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue)str

Converts an emulator value into a concatenated string.

Parameters

v (SiliconExcelEmulatorValue) – The emulator value.

Returns

Returns the concatenated string if successful; otherwise returns an empty string.

Return type

str

See also SiliconExcelEmulatorValue.

valueToSpreadsheetValue(value: Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue)Pro.SiliconSpreadsheet.SiliconSpreadsheetValue

Converts an emulator value into a spreadsheet value.

Parameters

value (SiliconExcelEmulatorValue) – The emulator value.

Returns

Returns the spreadsheet value if successful; otherwise returns an invalid spreadsheet value.

Return type

SiliconSpreadsheetValue

See also SiliconExcelEmulatorValue and SiliconSpreadsheetValue.

valueToString(v: Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue)str

Converts an emulator value to string.

Parameters

v (SiliconExcelEmulatorValue) – The emulator value.

Returns

Returns the value string if successful; otherwise returns an empty string.

Return type

str

See also SiliconExcelEmulatorValue.

class SiliconExcelEmulatorCtx

This class represents an Excel macro emulator context containing the formula being evaluated and its associated spreadsheet index, which is needed to resolve relative cell names.

See also SiliconExcelEmulator.

Attributes:

formula

The formula being evaluated.

idx

The spreadsheet index.

formula

The formula being evaluated.

See also idx.

idx

The spreadsheet index.

See also formula and SiliconSpreadsheetIndex.

class SiliconExcelEmulatorHelper

This class can be used to extend the Excel macro emulator.

See also SiliconExcelEmulator.

Methods:

evaluateFunction(emu, ctx, opts, depth, e)

Evaluates a function and returns the result.

evaluateFunction(emu: Pro.SiliconSpreadsheet.SiliconExcelEmulator, ctx: Pro.SiliconSpreadsheet.SiliconExcelEmulatorCtx, opts: int, depth: int, e: Pro.SiliconSpreadsheet.SiliconExcelExpr)Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue

Evaluates a function and returns the result.

Parameters
Returns

Returns a valid value if the function has been evaluated; otherwise returns an empty SiliconExcelEmulatorValue instance.

Return type

SiliconExcelEmulatorValue

See also SiliconExcelEmulatorValue, SiliconExcelEmulatorCtx and SiliconExcelExpr.

class SiliconExcelEmulatorValue

This class represents an Excel emulator value.

See also SiliconExcelEmulator.

Methods:

getValue()

Returns the value.

toBool()

Returns the value as boolean.

toNumber()

Returns the value as number.

toString()

Returns the value as string.

Attributes:

type

The value type (e.g., SiliconSpreadsheetValueType_String).

getValue()Optional[Union[int, float, bool, bytes, str]]
Returns

Returns the value.

Return type

BasicType

toBool()bool
Returns

Returns the value as boolean.

Return type

bool

toNumber()float
Returns

Returns the value as number.

Return type

float

toString()str
Returns

Returns the value as string.

Return type

str

type

The value type (e.g., SiliconSpreadsheetValueType_String).

class SiliconExcelEmulatorValueList

List of SiliconExcelEmulatorValue elements.

Methods:

append(value)

Inserts value at the end of the list.

at(i)

Returns the item at index position i in the list.

clear()

Removes all items from the list.

contains(value)

Checks the presence of an element in the list.

count(value)

Returns the number of occurrences of value in the list.

indexOf(value[, start])

Searches for an element in the list.

insert(i, value)

Inserts value at index position i in the list.

isEmpty()

Checks whether the list is empty.

iterator()

Creates an iterator for the list.

removeAll(value)

Removes all occurrences of value in the list and returns the number of entries removed.

removeAt(i)

Removes the item at index position i.

reserve(alloc)

Reserve space for alloc elements.

size()

Returns the number of items in the list.

takeAt(i)

Removes the item at index position i and returns it.

append(value: Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue)None

Inserts value at the end of the list.

Parameters

value (SiliconExcelEmulatorValue) – The value to add to the list.

See also insert().

at(i: int)Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue

Returns the item at index position i in the list. i must be a valid index position in the list (i.e., 0 <= i < size()).

Parameters

i (int) – The index of the element to return.

Returns

Returns the requested element.

Return type

SiliconExcelEmulatorValue

clear()None

Removes all items from the list.

contains(value: Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue)bool

Checks the presence of an element in the list.

Parameters

value (SiliconExcelEmulatorValue) – The value to check for.

Returns

Returns True if the list contains an occurrence of value; otherwise returns False.

Return type

bool

See also indexOf() and count().

count(value: Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue)int

Returns the number of occurrences of value in the list.

Parameters

value (SiliconExcelEmulatorValue) – The value to count.

Returns

Returns the number of occurrences.

Return type

int

See also indexOf() and contains().

indexOf(value: Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue, start: int = 0)int

Searches for an element in the list.

Parameters
Returns

Returns the index position of the first occurrence of value in the list. Returns -1 if no item was found.

Return type

int

See also contains().

insert(i: int, value: Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue)None

Inserts value at index position i in the list. If i is 0, the value is prepended to the list. If i is size(), the value is appended to the list.

Parameters

See also append() and removeAt().

isEmpty()bool

Checks whether the list is empty.

Returns

Returns True if the list contains no items; otherwise returns False.

Return type

bool

See also size().

iterator()Pro.SiliconSpreadsheet.SiliconExcelEmulatorValueListIt

Creates an iterator for the list.

Returns

Returns the iterator.

Return type

SiliconExcelEmulatorValueListIt

removeAll(value: Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue)int

Removes all occurrences of value in the list and returns the number of entries removed.

Parameters

value (SiliconExcelEmulatorValue) – The value to remove from the list.

Returns

Returns the number of entries removed.

Return type

int

See also removeAt().

removeAt(i: int)None

Removes the item at index position i. i must be a valid index position in the list (i.e., 0 <= i < size()).

Parameters

i (int) – The index of the item to remove.

See also removeAll().

reserve(alloc: int)None

Reserve space for alloc elements. Calling this method doesn’t change the size of the list.

Parameters

alloc (int) – The amount of elements to reserve space for.

size()int
Returns

Returns the number of items in the list.

Return type

int

See also isEmpty().

takeAt(i: int)Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue

Removes the item at index position i and returns it. i must be a valid index position in the list (i.e., 0 <= i < size()).

Parameters

i (int) – The index of the element to remove from the list.

Returns

Returns the removed element. If you don’t use the return value, removeAt() is more efficient.

Return type

SiliconExcelEmulatorValue

See also removeAt().

class SiliconExcelEmulatorValueListIt(obj: Pro.SiliconSpreadsheet.SiliconExcelEmulatorValueList)

Iterator class for SiliconExcelEmulatorValueList.

Parameters

obj (SiliconExcelEmulatorValueList) – The object to iterate over.

Methods:

hasNext()

Returns True if there is at least one item ahead of the iterator, i.e. the iterator is not at the back of the container; otherwise returns False.

hasPrevious()

Returns True if there is at least one item behind the iterator, i.e. the iterator is not at the front of the container; otherwise returns False.

next()

Returns the next item and advances the iterator by one position.

previous()

Returns the previous item and moves the iterator back by one position.

toBack()

Moves the iterator to the back of the container (after the last item).

toFront()

Moves the iterator to the front of the container (before the first item).

hasNext()bool
Returns

Returns True if there is at least one item ahead of the iterator, i.e. the iterator is not at the back of the container; otherwise returns False.

Return type

bool

See also hasPrevious() and next().

hasPrevious()bool
Returns

Returns True if there is at least one item behind the iterator, i.e. the iterator is not at the front of the container; otherwise returns False.

Return type

bool

See also hasNext() and previous().

next()Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue
Returns

Returns the next item and advances the iterator by one position.

Return type

SiliconExcelEmulatorValue

See also hasNext() and previous().

previous()Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue
Returns

Returns the previous item and moves the iterator back by one position.

Return type

SiliconExcelEmulatorValue

See also hasPrevious() and next().

toBack()None

Moves the iterator to the back of the container (after the last item).

See also toFront() and previous().

toFront()None

Moves the iterator to the front of the container (before the first item).

See also toBack() and next().

class SiliconExcelExpr

This class represents a parsed Excel macro expression as AST.

Attributes:

args

The arguments of the expression if available; otherwise None.

l

The left branch of the expression if available; otherwise None.

r

The right branch of the expression if available; otherwise None.

type

The type of the expression (e.g., SI_EXCEL_TOKEN_AND).

Methods:

getData()

Returns the data of the expression if available; otherwise returns None.

isArray()

Returns True if the expression is an array; otherwise returns False.

isBool()

Returns True if the expression is a boolean value; otherwise returns False.

isCell()

Returns True if the expression is a cell reference; otherwise returns False.

isCellRange()

Returns True if the expression is a cell range reference; otherwise returns False.

isComp()

Returns True if the expression is a comparison; otherwise returns False.

isError()

Returns True if the expression is an error value; otherwise returns False.

isFunction()

Returns True if the expression is a function; otherwise returns False.

isNull()

Returns True if the expression is a null value; otherwise returns False.

isNumber()

Returns True if the expression is a number; otherwise returns False.

isOp()

Returns True if the expression is an operation; otherwise returns False.

isSimpleValue()

Returns True if the expression is a basic value (i.e., not an array); otherwise returns False.

isString()

Returns True if the expression is a string value; otherwise returns False.

isValue()

Returns True if the expression is a value; otherwise returns False.

toBool()

Returns the expression value as boolean if possible; otherwise returns False.

toNumber()

Returns the expression value as number if possible; otherwise returns 0.

toString()

Returns the expression value as string if possible; otherwise returns an empty string.

args

The arguments of the expression if available; otherwise None.

See also SiliconExcelExprList, isFunction() and isArray().

getData()Optional[Union[int, float, bool, bytes, str]]
Returns

Returns the data of the expression if available; otherwise returns None.

Return type

BasicType

isArray()bool
Returns

Returns True if the expression is an array; otherwise returns False.

Return type

bool

isBool()bool
Returns

Returns True if the expression is a boolean value; otherwise returns False.

Return type

bool

isCell()bool
Returns

Returns True if the expression is a cell reference; otherwise returns False.

Return type

bool

isCellRange()bool
Returns

Returns True if the expression is a cell range reference; otherwise returns False.

Return type

bool

isComp()bool
Returns

Returns True if the expression is a comparison; otherwise returns False.

Return type

bool

isError()bool
Returns

Returns True if the expression is an error value; otherwise returns False.

Return type

bool

isFunction()bool
Returns

Returns True if the expression is a function; otherwise returns False.

Return type

bool

isNull()bool
Returns

Returns True if the expression is a null value; otherwise returns False.

Return type

bool

isNumber()bool
Returns

Returns True if the expression is a number; otherwise returns False.

Return type

bool

isOp()bool
Returns

Returns True if the expression is an operation; otherwise returns False.

Return type

bool

isSimpleValue()bool
Returns

Returns True if the expression is a basic value (i.e., not an array); otherwise returns False.

Return type

bool

isString()bool
Returns

Returns True if the expression is a string value; otherwise returns False.

Return type

bool

isValue()bool
Returns

Returns True if the expression is a value; otherwise returns False.

Return type

bool

l

The left branch of the expression if available; otherwise None.

See also SiliconExcelExpr.

r

The right branch of the expression if available; otherwise None.

See also SiliconExcelExpr.

toBool()bool
Returns

Returns the expression value as boolean if possible; otherwise returns False.

Return type

bool

toNumber()float
Returns

Returns the expression value as number if possible; otherwise returns 0.

Return type

float

toString()str
Returns

Returns the expression value as string if possible; otherwise returns an empty string.

Return type

str

type

The type of the expression (e.g., SI_EXCEL_TOKEN_AND).

class SiliconExcelExprList

List of SiliconExcelExpr elements.

Methods:

append(value)

Inserts value at the end of the list.

at(i)

Returns the item at index position i in the list.

clear()

Removes all items from the list.

contains(value)

Checks the presence of an element in the list.

count(value)

Returns the number of occurrences of value in the list.

indexOf(value[, start])

Searches for an element in the list.

insert(i, value)

Inserts value at index position i in the list.

isEmpty()

Checks whether the list is empty.

iterator()

Creates an iterator for the list.

removeAll(value)

Removes all occurrences of value in the list and returns the number of entries removed.

removeAt(i)

Removes the item at index position i.

reserve(alloc)

Reserve space for alloc elements.

size()

Returns the number of items in the list.

takeAt(i)

Removes the item at index position i and returns it.

append(value: Pro.SiliconSpreadsheet.SiliconExcelExpr)None

Inserts value at the end of the list.

Parameters

value (SiliconExcelExpr) – The value to add to the list.

See also insert().

at(i: int)Pro.SiliconSpreadsheet.SiliconExcelExpr

Returns the item at index position i in the list. i must be a valid index position in the list (i.e., 0 <= i < size()).

Parameters

i (int) – The index of the element to return.

Returns

Returns the requested element.

Return type

SiliconExcelExpr

clear()None

Removes all items from the list.

contains(value: Pro.SiliconSpreadsheet.SiliconExcelExpr)bool

Checks the presence of an element in the list.

Parameters

value (SiliconExcelExpr) – The value to check for.

Returns

Returns True if the list contains an occurrence of value; otherwise returns False.

Return type

bool

See also indexOf() and count().

count(value: Pro.SiliconSpreadsheet.SiliconExcelExpr)int

Returns the number of occurrences of value in the list.

Parameters

value (SiliconExcelExpr) – The value to count.

Returns

Returns the number of occurrences.

Return type

int

See also indexOf() and contains().

indexOf(value: Pro.SiliconSpreadsheet.SiliconExcelExpr, start: int = 0)int

Searches for an element in the list.

Parameters
  • value (SiliconExcelExpr) – The value to search for.

  • start (int) – The start index.

Returns

Returns the index position of the first occurrence of value in the list. Returns -1 if no item was found.

Return type

int

See also contains().

insert(i: int, value: Pro.SiliconSpreadsheet.SiliconExcelExpr)None

Inserts value at index position i in the list. If i is 0, the value is prepended to the list. If i is size(), the value is appended to the list.

Parameters
  • i (int) – The position at which to add the value.

  • value (SiliconExcelExpr) – The value to add.

See also append() and removeAt().

isEmpty()bool

Checks whether the list is empty.

Returns

Returns True if the list contains no items; otherwise returns False.

Return type

bool

See also size().

iterator()Pro.SiliconSpreadsheet.SiliconExcelExprListIt

Creates an iterator for the list.

Returns

Returns the iterator.

Return type

SiliconExcelExprListIt

removeAll(value: Pro.SiliconSpreadsheet.SiliconExcelExpr)int

Removes all occurrences of value in the list and returns the number of entries removed.

Parameters

value (SiliconExcelExpr) – The value to remove from the list.

Returns

Returns the number of entries removed.

Return type

int

See also removeAt().

removeAt(i: int)None

Removes the item at index position i. i must be a valid index position in the list (i.e., 0 <= i < size()).

Parameters

i (int) – The index of the item to remove.

See also removeAll().

reserve(alloc: int)None

Reserve space for alloc elements. Calling this method doesn’t change the size of the list.

Parameters

alloc (int) – The amount of elements to reserve space for.

size()int
Returns

Returns the number of items in the list.

Return type

int

See also isEmpty().

takeAt(i: int)Pro.SiliconSpreadsheet.SiliconExcelExpr

Removes the item at index position i and returns it. i must be a valid index position in the list (i.e., 0 <= i < size()).

Parameters

i (int) – The index of the element to remove from the list.

Returns

Returns the removed element. If you don’t use the return value, removeAt() is more efficient.

Return type

SiliconExcelExpr

See also removeAt().

class SiliconExcelExprListIt(obj: Pro.SiliconSpreadsheet.SiliconExcelExprList)

Iterator class for SiliconExcelExprList.

Parameters

obj (SiliconExcelExprList) – The object to iterate over.

Methods:

hasNext()

Returns True if there is at least one item ahead of the iterator, i.e. the iterator is not at the back of the container; otherwise returns False.

hasPrevious()

Returns True if there is at least one item behind the iterator, i.e. the iterator is not at the front of the container; otherwise returns False.

next()

Returns the next item and advances the iterator by one position.

previous()

Returns the previous item and moves the iterator back by one position.

toBack()

Moves the iterator to the back of the container (after the last item).

toFront()

Moves the iterator to the front of the container (before the first item).

hasNext()bool
Returns

Returns True if there is at least one item ahead of the iterator, i.e. the iterator is not at the back of the container; otherwise returns False.

Return type

bool

See also hasPrevious() and next().

hasPrevious()bool
Returns

Returns True if there is at least one item behind the iterator, i.e. the iterator is not at the front of the container; otherwise returns False.

Return type

bool

See also hasNext() and previous().

next()Pro.SiliconSpreadsheet.SiliconExcelExpr
Returns

Returns the next item and advances the iterator by one position.

Return type

SiliconExcelExpr

See also hasNext() and previous().

previous()Pro.SiliconSpreadsheet.SiliconExcelExpr
Returns

Returns the previous item and moves the iterator back by one position.

Return type

SiliconExcelExpr

See also hasPrevious() and next().

toBack()None

Moves the iterator to the back of the container (after the last item).

See also toFront() and previous().

toFront()None

Moves the iterator to the front of the container (before the first item).

See also toBack() and next().

class SiliconSpreadsheetCell

This class represents a spreadsheet cell value.

See also SiliconSpreadsheetIndex and SiliconSpreadsheetCellIndex.

Attributes:

formula

The formula of the cell as string.

value

The value of the cell as string.

value_type

The type of the cell value (e.g., SiliconSpreadsheetValueType_String).

Methods:

isEmpty()

Returns True if the cell is empty; otherwise returns False.

formula

The formula of the cell as string.

See also value and value_type.

isEmpty()bool
Returns

Returns True if the cell is empty; otherwise returns False.

Return type

bool

value

The value of the cell as string.

See also value_type and formula.

value_type

The type of the cell value (e.g., SiliconSpreadsheetValueType_String).

See also value and formula.

class SiliconSpreadsheetCellIndex

This class represents a spreadsheet cell index and its value.

See also SiliconSpreadsheetIndex and SiliconSpreadsheetCell.

Attributes:

cell

The value of the cell.

index

The index of the cell.

cell

The value of the cell.

See also index and SiliconSpreadsheetCell.

index

The index of the cell.

See also cell and SiliconSpreadsheetIndex.

class SiliconSpreadsheetCellIterator(sheet_or_ws: Union[Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet, Pro.SiliconSpreadsheet.SiliconSpreadsheetWorkspace])

An iterator for the cells in a workspace or in a single spreadsheet.

Parameters

sheet_or_ws (Union[SiliconSpreadsheetSheet, SiliconSpreadsheetWorkspace]) – The workspace or the spreadsheet.

See also SiliconSpreadsheetWorkspace and SiliconSpreadsheetSheet.

Methods:

hasNext()

Returns True if there is at least one cell ahead of the iterator; otherwise returns False.

next()

Returns the next cell.

hasNext()bool
Returns

Returns True if there is at least one cell ahead of the iterator; otherwise returns False.

Return type

bool

See also next().

next()Pro.SiliconSpreadsheet.SiliconSpreadsheetCellIndex
Returns

Returns the next cell.

Return type

SiliconSpreadsheetCellIndex

See also hasNext() and SiliconSpreadsheetCellIndex.

class SiliconSpreadsheetIndex

This class represents a spreadsheet index.

See also SiliconSpreadsheetCell and SiliconSpreadsheetCellIndex.

Methods:

absolute(current)

Converts a relative index to an absolute one.

isNull()

Returns True if the index is invalid; otherwise returns False.

isRelative()

Returns True if either the column or row coordinate of the index is relative; otherwise returns False.

isValid()

Returns True if the index is valid; otherwise returns False.

Attributes:

column

The column of the cell.

relative_column

If True, then column is a relative coordinate.

releative_row

If True, then row is a relative coordinate.

row

The row of the cell.

sheet

The name of the spreadsheet.

absolute(current: Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex)Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex

Converts a relative index to an absolute one.

Parameters

current (SiliconSpreadsheetIndex) – The reference index to be used for the conversion.

Returns

Returns the absolute index if successful; otherwise returns an invalid index.

Return type

SiliconSpreadsheetIndex

See also isRelative().

column

The column of the cell.

See also row, relative_column and isRelative().

isNull()bool
Returns

Returns True if the index is invalid; otherwise returns False.

Return type

bool

See also isValid().

isRelative()bool
Returns

Returns True if either the column or row coordinate of the index is relative; otherwise returns False.

Return type

bool

See also absolute().

isValid()bool
Returns

Returns True if the index is valid; otherwise returns False.

Return type

bool

See also isNull().

relative_column

If True, then column is a relative coordinate.

See also column, relative_row and isRelative().

releative_row

If True, then row is a relative coordinate.

See also row, relative_column and isRelative().

row

The row of the cell.

See also column, releative_row and isRelative().

sheet

The name of the spreadsheet.

class SiliconSpreadsheetRange

This class represents a spreadsheet index range.

Attributes:

a

The start index of the range.

b

The end index of the range.

Methods:

isNull()

Returns True if the index range is invalid; otherwise returns False.

isValid()

Returns True if the index range is valid; otherwise returns False.

a

The start index of the range.

See also SiliconSpreadsheetIndex and b.

b

The end index of the range.

See also SiliconSpreadsheetIndex and a.

isNull()bool
Returns

Returns True if the index range is invalid; otherwise returns False.

Return type

bool

See also isValid().

isValid()bool
Returns

Returns True if the index range is valid; otherwise returns False.

Return type

bool

See also isNull().

class SiliconSpreadsheetSheet(name: Optional[str] = None)

This class represents an individual spreadsheet sheet.

Parameters

name (Optional[str]) – The name of the sheet.

See also SiliconSpreadsheetWorkspace.

Methods:

addCell(column, row, value_type, value[, …])

Adds a cell to the sheet.

cellIterator()

Returns a cell iterator for the sheet.

columnCount()

Returns the number of columns in the sheet.

getCell(column, row)

Retrieves the value of a cell.

getDescr()

Returns a description for the sheet which is composed by its name and type name.

getName()

Returns the name of the sheet.

getType()

Returns the type name of the sheet.

isChanged()

Returns True if the sheet was modified; otherwise returns False.

isNull()

Returns True if the sheet is invalid; otherwise returns False.

isValid()

Returns True if the sheet is valid; otherwise returns False.

removeCell(column, row)

Removes a cell from the sheet.

rowCount()

Returns the number of rows in the sheet.

setChanged(b)

Sets the sheet modified status.

setType(t)

Sets the type name of the sheet.

addCell(column: int, row: int, value_type: int, value: str, formula: str = str())None

Adds a cell to the sheet.

Note

If the cell already exists, it will be replaced.

Parameters
  • column (int) – The column of the cell to add.

  • row (int) – The row of the cell to add.

  • value_type (int) – The type of value of the cell (e.g., SiliconSpreadsheetValueType_String).

  • value (str) – The value of the cell as string.

  • formula (str) – The formula of the cell as string.

See also getCell() and removeCell().

cellIterator()Pro.SiliconSpreadsheet.SiliconSpreadsheetCellIterator
Returns

Returns a cell iterator for the sheet.

Return type

SiliconSpreadsheetCellIterator

See also SiliconSpreadsheetCellIterator

columnCount()int
Returns

Returns the number of columns in the sheet.

Return type

int

See also rowCount(), getCell() and cellIterator().

getCell(column: int, row: int)Pro.SiliconSpreadsheet.SiliconSpreadsheetCell

Retrieves the value of a cell.

Parameters
  • column (int) – The column of the cell.

  • row (int) – The row of the cell.

Returns

Returns the value of the requested cell.

Return type

SiliconSpreadsheetCell

See also addCell() and removeCell().

getDescr()str
Returns

Returns a description for the sheet which is composed by its name and type name.

Return type

str

See also getName() and getType().

getName()str
Returns

Returns the name of the sheet.

Return type

str

See also getType() and getDescr().

getType()str
Returns

Returns the type name of the sheet.

Return type

str

See also setType() and getName().

isChanged()bool
Returns

Returns True if the sheet was modified; otherwise returns False.

Return type

bool

See also setChanged().

isNull()bool
Returns

Returns True if the sheet is invalid; otherwise returns False.

Return type

bool

See also isValid().

isValid()bool
Returns

Returns True if the sheet is valid; otherwise returns False.

Return type

bool

See also isNull().

removeCell(column: int, row: int)None

Removes a cell from the sheet.

Parameters
  • column (int) – The column of the cell to remove.

  • row (int) – The row of the cell to remove.

See also addCell() and getCell().

rowCount()int
Returns

Returns the number of rows in the sheet.

Return type

int

See also columnCount(), getCell() and cellIterator().

setChanged(b: bool)None

Sets the sheet modified status.

Parameters

b (bool) – If True, the sheet is marked as modified; otherwise it is marked as unmodified.

See also isChanged().

setType(t: str)None

Sets the type name of the sheet.

Parameters

t (str) – The type name to set.

See also getType().

class SiliconSpreadsheetSheetList

List of SiliconSpreadsheetSheet elements.

Methods:

append(value)

Inserts value at the end of the list.

at(i)

Returns the item at index position i in the list.

clear()

Removes all items from the list.

contains(value)

Checks the presence of an element in the list.

count(value)

Returns the number of occurrences of value in the list.

indexOf(value[, start])

Searches for an element in the list.

insert(i, value)

Inserts value at index position i in the list.

isEmpty()

Checks whether the list is empty.

iterator()

Creates an iterator for the list.

removeAll(value)

Removes all occurrences of value in the list and returns the number of entries removed.

removeAt(i)

Removes the item at index position i.

reserve(alloc)

Reserve space for alloc elements.

size()

Returns the number of items in the list.

takeAt(i)

Removes the item at index position i and returns it.

append(value: Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet)None

Inserts value at the end of the list.

Parameters

value (SiliconSpreadsheetSheet) – The value to add to the list.

See also insert().

at(i: int)Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet

Returns the item at index position i in the list. i must be a valid index position in the list (i.e., 0 <= i < size()).

Parameters

i (int) – The index of the element to return.

Returns

Returns the requested element.

Return type

SiliconSpreadsheetSheet

clear()None

Removes all items from the list.

contains(value: Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet)bool

Checks the presence of an element in the list.

Parameters

value (SiliconSpreadsheetSheet) – The value to check for.

Returns

Returns True if the list contains an occurrence of value; otherwise returns False.

Return type

bool

See also indexOf() and count().

count(value: Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet)int

Returns the number of occurrences of value in the list.

Parameters

value (SiliconSpreadsheetSheet) – The value to count.

Returns

Returns the number of occurrences.

Return type

int

See also indexOf() and contains().

indexOf(value: Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet, start: int = 0)int

Searches for an element in the list.

Parameters
Returns

Returns the index position of the first occurrence of value in the list. Returns -1 if no item was found.

Return type

int

See also contains().

insert(i: int, value: Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet)None

Inserts value at index position i in the list. If i is 0, the value is prepended to the list. If i is size(), the value is appended to the list.

Parameters

See also append() and removeAt().

isEmpty()bool

Checks whether the list is empty.

Returns

Returns True if the list contains no items; otherwise returns False.

Return type

bool

See also size().

iterator()Pro.SiliconSpreadsheet.SiliconSpreadsheetSheetListIt

Creates an iterator for the list.

Returns

Returns the iterator.

Return type

SiliconSpreadsheetSheetListIt

removeAll(value: Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet)int

Removes all occurrences of value in the list and returns the number of entries removed.

Parameters

value (SiliconSpreadsheetSheet) – The value to remove from the list.

Returns

Returns the number of entries removed.

Return type

int

See also removeAt().

removeAt(i: int)None

Removes the item at index position i. i must be a valid index position in the list (i.e., 0 <= i < size()).

Parameters

i (int) – The index of the item to remove.

See also removeAll().

reserve(alloc: int)None

Reserve space for alloc elements. Calling this method doesn’t change the size of the list.

Parameters

alloc (int) – The amount of elements to reserve space for.

size()int
Returns

Returns the number of items in the list.

Return type

int

See also isEmpty().

takeAt(i: int)Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet

Removes the item at index position i and returns it. i must be a valid index position in the list (i.e., 0 <= i < size()).

Parameters

i (int) – The index of the element to remove from the list.

Returns

Returns the removed element. If you don’t use the return value, removeAt() is more efficient.

Return type

SiliconSpreadsheetSheet

See also removeAt().

class SiliconSpreadsheetSheetListIt(obj: Pro.SiliconSpreadsheet.SiliconSpreadsheetSheetList)

Iterator class for SiliconSpreadsheetSheetList.

Parameters

obj (SiliconSpreadsheetSheetList) – The object to iterate over.

Methods:

hasNext()

Returns True if there is at least one item ahead of the iterator, i.e. the iterator is not at the back of the container; otherwise returns False.

hasPrevious()

Returns True if there is at least one item behind the iterator, i.e. the iterator is not at the front of the container; otherwise returns False.

next()

Returns the next item and advances the iterator by one position.

previous()

Returns the previous item and moves the iterator back by one position.

toBack()

Moves the iterator to the back of the container (after the last item).

toFront()

Moves the iterator to the front of the container (before the first item).

hasNext()bool
Returns

Returns True if there is at least one item ahead of the iterator, i.e. the iterator is not at the back of the container; otherwise returns False.

Return type

bool

See also hasPrevious() and next().

hasPrevious()bool
Returns

Returns True if there is at least one item behind the iterator, i.e. the iterator is not at the front of the container; otherwise returns False.

Return type

bool

See also hasNext() and previous().

next()Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet
Returns

Returns the next item and advances the iterator by one position.

Return type

SiliconSpreadsheetSheet

See also hasNext() and previous().

previous()Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet
Returns

Returns the previous item and moves the iterator back by one position.

Return type

SiliconSpreadsheetSheet

See also hasPrevious() and next().

toBack()None

Moves the iterator to the back of the container (after the last item).

See also toFront() and previous().

toFront()None

Moves the iterator to the front of the container (before the first item).

See also toBack() and next().

class SiliconSpreadsheetUtil

This class contains static methods to convert spreadsheet indexes to and from strings.

Methods:

cellIndex(name)

Converts a cell name to a spreadsheet index.

cellName(idx_or_rowx[, colx])

Converts a spreadsheet index into a cell name.

cellRange(str)

Converts a cell range string into a spreadsheet index range.

colIndex(colname)

Converts the name of a column into its index.

colName(colx)

Converts the index of a column into its name.

static cellIndex(name: str)Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex

Converts a cell name to a spreadsheet index.

Parameters

name (str) – The name of the cell.

Returns

Returns the spreadsheet index if successful; otherwise returns an invalid index.

Return type

SiliconSpreadsheetIndex

See also cellRange(), cellName() and SiliconSpreadsheetIndex.

static cellName(idx_or_rowx: Union[Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex, int], colx: Optional[int] = None)str

Converts a spreadsheet index into a cell name.

Parameters
  • idx_or_rowx (Union[SiliconSpreadsheetIndex, int]) – The row of the cell or its index.

  • colx (Optional[int]) – The column of the cell.

Returns

Returns the name of the cell.

Return type

str

See also cellIndex() and SiliconSpreadsheetIndex.

static cellRange(str: str)Pro.SiliconSpreadsheet.SiliconSpreadsheetRange

Converts a cell range string into a spreadsheet index range.

Parameters

str (str) – The cell range string.

Returns

Returns a spreadsheet index range if successful; otherwise returns an invalid spreadsheet index range.

Return type

SiliconSpreadsheetRange

See also cellIndex() and SiliconSpreadsheetIndex.

static colIndex(colname: str)int

Converts the name of a column into its index.

Parameters

colname (str) – The name of the column.

Returns

Returns the index of the column.

Return type

int

See also colName().

static colName(colx: int)str

Converts the index of a column into its name.

Parameters

colx (int) – The index of the column.

Returns

Returns the name of the column.

Return type

str

See also colIndex().

class SiliconSpreadsheetValue

This class represents a spreadsheet value.

Attributes:

type

The type of value (e.g., SiliconSpreadsheetValueType_String).

value

The value as string.

type

The type of value (e.g., SiliconSpreadsheetValueType_String).

See also value.

value

The value as string.

See also type.

SiliconSpreadsheetValueType_Array: Final[int]

Spreadsheet array value type.

See also SiliconExcelEmulatorValue.type.

SiliconSpreadsheetValueType_Boolean: Final[int]

Spreadsheet boolean value type.

See also SiliconExcelEmulatorValue.type.

SiliconSpreadsheetValueType_Cell: Final[int]

Spreadsheet cell reference value type.

See also SiliconExcelEmulatorValue.type.

SiliconSpreadsheetValueType_CellRange: Final[int]

Spreadsheet cell range reference value type.

See also SiliconExcelEmulatorValue.type.

SiliconSpreadsheetValueType_Error: Final[int]

Spreadsheet error value type.

See also SiliconExcelEmulatorValue.type.

SiliconSpreadsheetValueType_Null: Final[int]

Spreadsheet null value type.

See also SiliconExcelEmulatorValue.type.

SiliconSpreadsheetValueType_Number: Final[int]

Spreadsheet number value type.

See also SiliconExcelEmulatorValue.type.

SiliconSpreadsheetValueType_String: Final[int]

Spreadsheet string value type.

See also SiliconExcelEmulatorValue.type.

SiliconSpreadsheetValueType_ToEvaluate: Final[int]

Spreadsheet minimum value type to evaluate.

See also SiliconExcelEmulatorValue.type.

SiliconSpreadsheetValueType_Unknown: Final[int]

Spreadsheet unknown value type.

See also SiliconExcelEmulatorValue.type.

class SiliconSpreadsheetWorkspace

This class represents a spreadsheet workspace (i.e., a collection of sheets).

See also SiliconSpreadsheetSheet.

Attributes:

WS_Excel

Excel workspace type.

WS_Unknown

Unknown workspace type.

Methods:

addDefinedName(name, formula)

Adds a defined name to the workspace.

addSheet(sheet)

Adds a sheet to the workspace.

cellIterator()

Returns a cell iterator for the workspace.

getCell(idx[, curidx])

Retrieves the value of a cell.

getDefinedNames()

Returns a hash of defined names.

getFormulaCell(idx)

Retrieves the first cell with a formula starting at the specified index and iterating through rows.

getSheet(i)

Retrieves the specified sheet.

getSheets()

Returns the list of sheets in the workspace.

getWorkspaceType()

Returns the type of workspace (e.g., WS_Excel).

hasDefinedNames()

Returns True if the workspace has defined names; otherwise returns False.

isCellValid(idx[, curidx])

Checks the presence of a cell.

resetSheetChangeStatus()

Resets the modified status of the sheets.

setWorkspaceType(type)

Sets the type of the workspace.

sheetChanged()

Returns True if one of the sheets has been marked as modified; otherwise returns False.

sheetFromName(name)

Retrieves a sheet from its name.

sheetIndexFromName(name)

Retrieves the index of a sheet from its name.

WS_Excel: Final[int]

Excel workspace type.

See also getWorkspaceType() and setWorkspaceType().

WS_Unknown: Final[int]

Unknown workspace type.

See also getWorkspaceType() and setWorkspaceType().

addDefinedName(name: str, formula: str)None

Adds a defined name to the workspace.

Parameters
  • name (str) – The defined name to add.

  • formula (str) – The formula associated to the defined name.

See also hasDefinedNames() and getDefinedNames().

addSheet(sheet: Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet)None

Adds a sheet to the workspace.

Parameters

sheet (SiliconSpreadsheetSheet) – The sheet to add.

See also getSheet(), getSheets() and SiliconSpreadsheetSheet.

cellIterator()Pro.SiliconSpreadsheet.SiliconSpreadsheetCellIterator
Returns

Returns a cell iterator for the workspace.

Return type

SiliconSpreadsheetCellIterator

See also SiliconSpreadsheetCellIterator.

getCell(idx: Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex, curidx: Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex = SiliconSpreadsheetIndex())Pro.SiliconSpreadsheet.SiliconSpreadsheetCell

Retrieves the value of a cell.

Parameters
Returns

Returns the cell value if successful; otherwise returns an invalid cell value.

Return type

SiliconSpreadsheetCell

See also SiliconSpreadsheetIndex and SiliconSpreadsheetCell.

getDefinedNames()Pro.Core.NTUTF8StringHash
Returns

Returns a hash of defined names.

Return type

NTUTF8StringHash

See also hasDefinedNames() and addDefinedName().

getFormulaCell(idx: Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex)Pro.SiliconSpreadsheet.SiliconSpreadsheetCellIndex

Retrieves the first cell with a formula starting at the specified index and iterating through rows.

Parameters

idx (SiliconSpreadsheetIndex) – The start index.

Returns

Returns the cell value and index if successful; otherwise returns an invalid SiliconSpreadsheetCellIndex.

Return type

SiliconSpreadsheetCellIndex

See also SiliconSpreadsheetIndex and SiliconSpreadsheetCellIndex.

getSheet(i: int)Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet

Retrieves the specified sheet.

Parameters

i (int) – The index of the sheet to retrieve.

Returns

Returns the requested sheet if successful otherwise returns an invalid sheet.

Return type

SiliconSpreadsheetSheet

See also addSheet(), getSheets() and SiliconSpreadsheetSheet.

getSheets()Pro.SiliconSpreadsheet.SiliconSpreadsheetSheetList
Returns

Returns the list of sheets in the workspace.

Return type

SiliconSpreadsheetSheetList

See also getSheet(), addSheet() and SiliconSpreadsheetSheet.

getWorkspaceType()int
Returns

Returns the type of workspace (e.g., WS_Excel).

Return type

int

See also setWorkspaceType().

hasDefinedNames()bool
Returns

Returns True if the workspace has defined names; otherwise returns False.

Return type

bool

See also addDefinedName() and getDefinedNames().

isCellValid(idx: Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex, curidx: Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex = SiliconSpreadsheetIndex())bool

Checks the presence of a cell.

Parameters
Returns

Returns True if the cell is present; otherwise returns False.

Return type

bool

See also getCell() and SiliconSpreadsheetIndex.

resetSheetChangeStatus()None

Resets the modified status of the sheets.

See also SiliconSpreadsheetSheet.setChanged().

setWorkspaceType(type: int)None

Sets the type of the workspace.

Parameters

type (int) – The workspace type (e.g., WS_Excel).

See also getWorkspaceType().

sheetChanged()bool
Returns

Returns True if one of the sheets has been marked as modified; otherwise returns False.

Return type

bool

See also SiliconSpreadsheetSheet.isChanged().

sheetFromName(name: str)Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet

Retrieves a sheet from its name.

Parameters

name (str) – The name of the sheet to retrieve.

Returns

Returns the sheet if successful; otherwise returns an invalid sheet.

Return type

SiliconSpreadsheetSheet

See also getSheet(), sheetIndexFromName() and SiliconSpreadsheetSheet.

sheetIndexFromName(name: str)int

Retrieves the index of a sheet from its name.

Parameters

name (str) – The name of the sheet.

Returns

Returns the index of the requested sheet if successful; otherwise returns -1.

Return type

int

See also getSheet(), sheetFromName() and SiliconSpreadsheetSheet.

class SiliconSpreadsheetWorkspaceView(view: ProView)

This class is used to interact with the view used to display a spreadsheet workspace.

See also siliconCreateSpreadsheetWorkspaceView().

Parameters

view (ProView) – The workspace view.

See also SiliconSpreadsheetWorkspace.

Methods:

currentCell()

Returns the index of the current cell if available; otherwise returns an invalid index.

getExcelEmulator()

Returns the Excel emulator if available; otherwise returns None.

getSpreadsheetWorkspace()

Returns the spreadsheet workspace if available; otherwise returns an invalid workspace.

goToCell(idx)

Jumps to a specified cell.

refreshSpreadsheets()

Refreshes the contents of the sheets.

currentCell()Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex
Returns

Returns the index of the current cell if available; otherwise returns an invalid index.

Return type

SiliconSpreadsheetIndex

See also goToCell().

getExcelEmulator()Pro.SiliconSpreadsheet.SiliconExcelEmulator
Returns

Returns the Excel emulator if available; otherwise returns None.

Return type

SiliconExcelEmulator

getSpreadsheetWorkspace()Pro.SiliconSpreadsheet.SiliconSpreadsheetWorkspace
Returns

Returns the spreadsheet workspace if available; otherwise returns an invalid workspace.

Return type

SiliconSpreadsheetWorkspace

goToCell(idx: Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex)None

Jumps to a specified cell.

Parameters

idx (SiliconSpreadsheetIndex) – The index of the cell.

See also currentCell().

refreshSpreadsheets()None

Refreshes the contents of the sheets.

siliconCreateSpreadsheetWorkspaceView(sdata: Pro.Core.ScanViewData, w: Pro.SiliconSpreadsheet.SiliconSpreadsheetWorkspace)None

Creates a spreadsheet workspace view.

Parameters