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:
SiliconSpreadsheetIndex
- This class represents a spreadsheet index.SiliconSpreadsheetRange
- This class represents a spreadsheet index range.SiliconSpreadsheetCell
- This class represents a spreadsheet cell value.SiliconSpreadsheetCellIndex
- This class represents a spreadsheet cell index and its value.SiliconSpreadsheetUtil
- This class contains static methods to convert spreadsheet indexes to and from strings.SiliconSpreadsheetSheet
- This class represents an individual spreadsheet sheet.SiliconSpreadsheetWorkspace
- This class represents a spreadsheet workspace (i.e., a collection of sheets).SiliconSpreadsheetWorkspaceView
- This class is used to interact with the view used to display a spreadsheet workspace.SiliconExcelExpr
- This class represents a parsed Excel macro expression as AST.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.SiliconExcelEmulatorValue
- This class represents an Excel emulator value.SiliconExcelEmulatorHelper
- This class can be used to extend the Excel macro emulator.SiliconExcelEmulator
- This class represents the Excel macro emulator.
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:
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Excel macro lexical token type.
Spreadsheet array value type.
Spreadsheet boolean value type.
Spreadsheet cell reference value type.
Spreadsheet cell range reference value type.
Spreadsheet error value type.
Spreadsheet null value type.
Spreadsheet number value type.
Spreadsheet string value type.
Spreadsheet minimum value type to evaluate.
Spreadsheet unknown value type.
Classes:
This class represents the Excel macro emulator.
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.
This class can be used to extend the Excel macro emulator.
This class represents an Excel emulator value.
List of
SiliconExcelEmulatorValue
elements.Iterator class for
SiliconExcelEmulatorValueList
.This class represents a parsed Excel macro expression as AST.
List of
SiliconExcelExpr
elements.Iterator class for
SiliconExcelExprList
.This class represents a spreadsheet cell value.
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.
This class represents a spreadsheet index.
This class represents a spreadsheet index range.
SiliconSpreadsheetSheet
(name)This class represents an individual spreadsheet sheet.
List of
SiliconSpreadsheetSheet
elements.Iterator class for
SiliconSpreadsheetSheetList
.This class contains static methods to convert spreadsheet indexes to and from strings.
This class represents a spreadsheet value.
This class represents a spreadsheet workspace (i.e., a collection of sheets).
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:
Evaluate references option for the emulation.
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.
Returns the emulator helper if available; otherwise returns
None
.Returns the maximum evaluation depth.
getWait
()Returns the emulator wait object if available; otherwise returns
None
.Returns the spreadsheet workspace.
Returns
True
if verbose output is enabled; otherwise returnsFalse
.
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.
Converts an emulator value into a concatenated string.
valueToSpreadsheetValue
(value)Converts an emulator value into a spreadsheet value.
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()
andargsToValueList()
.
- 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
ctx (SiliconExcelEmulatorCtx) – The emulator context.
opts (int) – The emulation options (e.g.,
EmulatorOpt_EvalReferences()
).depth (int) – The current evaluation depth.
e (SiliconExcelExpr) – The expression.
i (int) – The index of the argument to convert.
- Returns
Returns the emulator value if successful; otherwise returns an invalid emulator value.
- Return type
See also
argCount()
andargsToValueList()
.
- 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
ctx (SiliconExcelEmulatorCtx) – The emulator context.
opts (int) – The emulation options (e.g.,
EmulatorOpt_EvalReferences()
).depth (int) – The current evaluation depth.
e (SiliconExcelExpr) – The expression.
- Returns
Returns the emulator value list if successful; otherwise returns an empty emulator value list.
- Return type
See also
argCount()
andargToValue()
.
- 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
See also
evaluateToString()
,SiliconSpreadsheetIndex
andSiliconExcelEmulatorValue
.
- evaluateStandardFunction(ctx: Pro.SiliconSpreadsheet.SiliconExcelEmulatorCtx, opts: int, depth: int, e: Pro.SiliconSpreadsheet.SiliconExcelExpr) → Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue¶
Evaluate a built-in function.
- Parameters
ctx (SiliconExcelEmulatorCtx) – The emulator context.
opts (int) – The emulation options (e.g.,
EmulatorOpt_EvalReferences()
).depth (int) – The current evaluation depth.
e (SiliconExcelExpr) – The expression to evaluate.
- Returns
Returns the result of the evaluation if successful; otherwise returns an invalid value.
- Return type
See also
evaluate()
,SiliconExcelEmulatorCtx
,SiliconExcelExpr
andSiliconExcelEmulatorValue
.
- 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()
andSiliconSpreadsheetIndex
.
- 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 returnsFalse
.- 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
ctx (SiliconExcelEmulatorCtx) – The emulator context.
opts (int) – The emulation options (e.g.,
EmulatorOpt_EvalReferences()
).depth (int) – The current evaluation depth.
e (SiliconExcelExpr) – The expression to convert.
- Returns
Returns the emulator value if successful; otherwise returns an invalid emulator value.
- Return type
See also
evaluate()
,SiliconExcelEmulatorCtx
,SiliconExcelExpr
andSiliconExcelEmulatorValue
.
- getHelper() → Pro.SiliconSpreadsheet.SiliconExcelEmulatorHelper¶
- Returns
Returns the emulator helper if available; otherwise returns
None
.- Return type
See also
setHelper()
andSiliconExcelEmulatorHelper
.
- 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
See also
setWait()
andPro.Core.NTIWait
.
- getWorkspace() → Pro.SiliconSpreadsheet.SiliconSpreadsheetWorkspace¶
- Returns
Returns the spreadsheet workspace.
- Return type
See also
setWorkspace()
andSiliconSpreadsheetWorkspace
.
- isVerbose() → bool¶
- Returns
Returns
True
if verbose output is enabled; otherwise returnsFalse
.- 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()
andSiliconExcelEmulatorHelper
.
- 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()
andPro.Core.NTIWait
.
- setWorkspace(w: Pro.SiliconSpreadsheet.SiliconSpreadsheetWorkspace) → None¶
Sets the spreadsheet workspace.
- Parameters
w (SiliconSpreadsheetWorkspace) – The spreadsheet workspace.
See also
getWorkspace()
andSiliconSpreadsheetWorkspace
.
- 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
See also
SiliconSpreadsheetCell
andSiliconExcelEmulatorValue
.
- 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
See also
SiliconExcelEmulatorValue
andSiliconSpreadsheetValue
.
- 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:
The formula being evaluated.
The spreadsheet index.
- idx¶
The spreadsheet index.
See also
formula
andSiliconSpreadsheetIndex
.
- 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
emu (SiliconExcelEmulator) – The emulator instance.
ctx (SiliconExcelEmulatorCtx) – The emulator context.
opts (int) – The options for the evaluation process (e.g.,
SiliconExcelEmulator.EmulatorOpt_EvalReferences
).depth (int) – The current evaluation depth.
e (SiliconExcelExpr) – The parsed expression.
- Returns
Returns a valid value if the function has been evaluated; otherwise returns an empty
SiliconExcelEmulatorValue
instance.- Return type
See also
SiliconExcelEmulatorValue
,SiliconExcelEmulatorCtx
andSiliconExcelExpr
.
- 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:
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 positioni
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
- 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 ofvalue
; otherwise returnsFalse
.- Return type
bool
- 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()
andcontains()
.
- indexOf(value: Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue, start: int = 0) → int¶
Searches for an element in the list.
- Parameters
value (SiliconExcelEmulatorValue) – 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.SiliconExcelEmulatorValue) → None¶
Inserts
value
at index positioni
in the list. Ifi
is0
, the value is prepended to the list. Ifi
issize()
, the value is appended to the list.
- Parameters
i (int) – The position at which to add the value.
value (SiliconExcelEmulatorValue) – The value to add.
See also
append()
andremoveAt()
.
- isEmpty() → bool¶
Checks whether the list is empty.
- Returns
Returns
True
if the list contains no items; otherwise returnsFalse
.- Return type
bool
See also
size()
.
- iterator() → Pro.SiliconSpreadsheet.SiliconExcelEmulatorValueListIt¶
Creates an iterator for the list.
- Returns
Returns the iterator.
- Return type
- 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.
- 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
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 returnsFalse
.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 returnsFalse
.
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 returnsFalse
.- Return type
bool
See also
hasPrevious()
andnext()
.
- 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 returnsFalse
.- Return type
bool
See also
hasNext()
andprevious()
.
- next() → Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue¶
- Returns
Returns the next item and advances the iterator by one position.
- Return type
See also
hasNext()
andprevious()
.
- previous() → Pro.SiliconSpreadsheet.SiliconExcelEmulatorValue¶
- Returns
Returns the previous item and moves the iterator back by one position.
- Return type
See also
hasPrevious()
andnext()
.
- toBack() → None¶
Moves the iterator to the back of the container (after the last item).
See also
toFront()
andprevious()
.
- class SiliconExcelExpr¶
This class represents a parsed Excel macro expression as AST.
Attributes:
The arguments of the expression if available; otherwise
None
.The left branch of the expression if available; otherwise
None
.The right branch of the expression if available; otherwise
None
.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 returnsFalse
.
isBool
()Returns
True
if the expression is a boolean value; otherwise returnsFalse
.
isCell
()Returns
True
if the expression is a cell reference; otherwise returnsFalse
.Returns
True
if the expression is a cell range reference; otherwise returnsFalse
.
isComp
()Returns
True
if the expression is a comparison; otherwise returnsFalse
.
isError
()Returns
True
if the expression is an error value; otherwise returnsFalse
.Returns
True
if the expression is a function; otherwise returnsFalse
.
isNull
()Returns
True
if the expression is a null value; otherwise returnsFalse
.
isNumber
()Returns
True
if the expression is a number; otherwise returnsFalse
.
isOp
()Returns
True
if the expression is an operation; otherwise returnsFalse
.Returns
True
if the expression is a basic value (i.e., not an array); otherwise returnsFalse
.
isString
()Returns
True
if the expression is a string value; otherwise returnsFalse
.
isValue
()Returns
True
if the expression is a value; otherwise returnsFalse
.
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()
andisArray()
.
- 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 returnsFalse
.- Return type
bool
- isBool() → bool¶
- Returns
Returns
True
if the expression is a boolean value; otherwise returnsFalse
.- Return type
bool
- isCell() → bool¶
- Returns
Returns
True
if the expression is a cell reference; otherwise returnsFalse
.- Return type
bool
- isCellRange() → bool¶
- Returns
Returns
True
if the expression is a cell range reference; otherwise returnsFalse
.- Return type
bool
- isComp() → bool¶
- Returns
Returns
True
if the expression is a comparison; otherwise returnsFalse
.- Return type
bool
- isError() → bool¶
- Returns
Returns
True
if the expression is an error value; otherwise returnsFalse
.- Return type
bool
- isFunction() → bool¶
- Returns
Returns
True
if the expression is a function; otherwise returnsFalse
.- Return type
bool
- isNull() → bool¶
- Returns
Returns
True
if the expression is a null value; otherwise returnsFalse
.- Return type
bool
- isNumber() → bool¶
- Returns
Returns
True
if the expression is a number; otherwise returnsFalse
.- Return type
bool
- isOp() → bool¶
- Returns
Returns
True
if the expression is an operation; otherwise returnsFalse
.- Return type
bool
- isSimpleValue() → bool¶
- Returns
Returns
True
if the expression is a basic value (i.e., not an array); otherwise returnsFalse
.- Return type
bool
- isString() → bool¶
- Returns
Returns
True
if the expression is a string value; otherwise returnsFalse
.- Return type
bool
- isValue() → bool¶
- Returns
Returns
True
if the expression is a value; otherwise returnsFalse
.- 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 positioni
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
- 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 ofvalue
; otherwise returnsFalse
.- Return type
bool
- 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()
andcontains()
.
- 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 positioni
in the list. Ifi
is0
, the value is prepended to the list. Ifi
issize()
, 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()
andremoveAt()
.
- isEmpty() → bool¶
Checks whether the list is empty.
- Returns
Returns
True
if the list contains no items; otherwise returnsFalse
.- Return type
bool
See also
size()
.
- iterator() → Pro.SiliconSpreadsheet.SiliconExcelExprListIt¶
Creates an iterator for the list.
- Returns
Returns the iterator.
- Return type
- 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.
- 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
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 returnsFalse
.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 returnsFalse
.
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 returnsFalse
.- Return type
bool
See also
hasPrevious()
andnext()
.
- 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 returnsFalse
.- Return type
bool
See also
hasNext()
andprevious()
.
- next() → Pro.SiliconSpreadsheet.SiliconExcelExpr¶
- Returns
Returns the next item and advances the iterator by one position.
- Return type
See also
hasNext()
andprevious()
.
- previous() → Pro.SiliconSpreadsheet.SiliconExcelExpr¶
- Returns
Returns the previous item and moves the iterator back by one position.
- Return type
See also
hasPrevious()
andnext()
.
- toBack() → None¶
Moves the iterator to the back of the container (after the last item).
See also
toFront()
andprevious()
.
- class SiliconSpreadsheetCell¶
This class represents a spreadsheet cell value.
See also
SiliconSpreadsheetIndex
andSiliconSpreadsheetCellIndex
.Attributes:
The formula of the cell as string.
The value of the cell as string.
The type of the cell value (e.g.,
SiliconSpreadsheetValueType_String
).Methods:
isEmpty
()Returns
True
if the cell is empty; otherwise returnsFalse
.
- formula¶
The formula of the cell as string.
See also
value
andvalue_type
.
- isEmpty() → bool¶
- Returns
Returns
True
if the cell is empty; otherwise returnsFalse
.- Return type
bool
- value¶
The value of the cell as string.
See also
value_type
andformula
.
- value_type¶
The type of the cell value (e.g.,
SiliconSpreadsheetValueType_String
).
- class SiliconSpreadsheetCellIndex¶
This class represents a spreadsheet cell index and its value.
See also
SiliconSpreadsheetIndex
andSiliconSpreadsheetCell
.Attributes:
The value of the cell.
The index of the cell.
- cell¶
The value of the cell.
See also
index
andSiliconSpreadsheetCell
.
- index¶
The index of the cell.
See also
cell
andSiliconSpreadsheetIndex
.
- 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
andSiliconSpreadsheetSheet
.Methods:
hasNext
()Returns
True
if there is at least one cell ahead of the iterator; otherwise returnsFalse
.
next
()Returns the next cell.
- hasNext() → bool¶
- Returns
Returns
True
if there is at least one cell ahead of the iterator; otherwise returnsFalse
.- Return type
bool
See also
next()
.
- next() → Pro.SiliconSpreadsheet.SiliconSpreadsheetCellIndex¶
- Returns
Returns the next cell.
- Return type
See also
hasNext()
andSiliconSpreadsheetCellIndex
.
- class SiliconSpreadsheetIndex¶
This class represents a spreadsheet index.
See also
SiliconSpreadsheetCell
andSiliconSpreadsheetCellIndex
.Methods:
absolute
(current)Converts a relative index to an absolute one.
isNull
()Returns
True
if the index is invalid; otherwise returnsFalse
.Returns
True
if either the column or row coordinate of the index is relative; otherwise returnsFalse
.
isValid
()Returns
True
if the index is valid; otherwise returnsFalse
.Attributes:
The column of the cell.
If
True
, thencolumn
is a relative coordinate.If
True
, thenrow
is a relative coordinate.The row of the cell.
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
See also
isRelative()
.
- column¶
The column of the cell.
See also
row
,relative_column
andisRelative()
.
- isNull() → bool¶
- Returns
Returns
True
if the index is invalid; otherwise returnsFalse
.- Return type
bool
See also
isValid()
.
- isRelative() → bool¶
- Returns
Returns
True
if either the column or row coordinate of the index is relative; otherwise returnsFalse
.- Return type
bool
See also
absolute()
.
- isValid() → bool¶
- Returns
Returns
True
if the index is valid; otherwise returnsFalse
.- Return type
bool
See also
isNull()
.
- relative_column¶
If
True
, thencolumn
is a relative coordinate.See also
column
,relative_row
andisRelative()
.
- releative_row¶
If
True
, thenrow
is a relative coordinate.See also
row
,relative_column
andisRelative()
.
- row¶
The row of the cell.
See also
column
,releative_row
andisRelative()
.
- sheet¶
The name of the spreadsheet.
- class SiliconSpreadsheetRange¶
This class represents a spreadsheet index range.
Attributes:
The start index of the range.
The end index of the range.
Methods:
isNull
()Returns
True
if the index range is invalid; otherwise returnsFalse
.
isValid
()Returns
True
if the index range is valid; otherwise returnsFalse
.
- a¶
The start index of the range.
See also
SiliconSpreadsheetIndex
andb
.
- b¶
The end index of the range.
See also
SiliconSpreadsheetIndex
anda
.
- 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.
Returns a cell iterator for the sheet.
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.
Returns
True
if the sheet was modified; otherwise returnsFalse
.
isNull
()Returns
True
if the sheet is invalid; otherwise returnsFalse
.
isValid
()Returns
True
if the sheet is valid; otherwise returnsFalse
.
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()
andremoveCell()
.
- cellIterator() → Pro.SiliconSpreadsheet.SiliconSpreadsheetCellIterator¶
- Returns
Returns a cell iterator for the sheet.
- Return type
See also
SiliconSpreadsheetCellIterator
- columnCount() → int¶
- Returns
Returns the number of columns in the sheet.
- Return type
int
See also
rowCount()
,getCell()
andcellIterator()
.
- 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
See also
addCell()
andremoveCell()
.
- getDescr() → str¶
- Returns
Returns a description for the sheet which is composed by its name and type name.
- Return type
str
- getName() → str¶
- Returns
Returns the name of the sheet.
- Return type
str
See also
getType()
andgetDescr()
.
- getType() → str¶
- Returns
Returns the type name of the sheet.
- Return type
str
- isChanged() → bool¶
- Returns
Returns
True
if the sheet was modified; otherwise returnsFalse
.- Return type
bool
See also
setChanged()
.
- isNull() → bool¶
- Returns
Returns
True
if the sheet is invalid; otherwise returnsFalse
.- Return type
bool
See also
isValid()
.
- isValid() → bool¶
- Returns
Returns
True
if the sheet is valid; otherwise returnsFalse
.- 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.
- rowCount() → int¶
- Returns
Returns the number of rows in the sheet.
- Return type
int
See also
columnCount()
,getCell()
andcellIterator()
.
- 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()
.
- 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 positioni
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
- 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 ofvalue
; otherwise returnsFalse
.- Return type
bool
- 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()
andcontains()
.
- indexOf(value: Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet, start: int = 0) → int¶
Searches for an element in the list.
- Parameters
value (SiliconSpreadsheetSheet) – 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.SiliconSpreadsheetSheet) → None¶
Inserts
value
at index positioni
in the list. Ifi
is0
, the value is prepended to the list. Ifi
issize()
, the value is appended to the list.
- Parameters
i (int) – The position at which to add the value.
value (SiliconSpreadsheetSheet) – The value to add.
See also
append()
andremoveAt()
.
- isEmpty() → bool¶
Checks whether the list is empty.
- Returns
Returns
True
if the list contains no items; otherwise returnsFalse
.- Return type
bool
See also
size()
.
- iterator() → Pro.SiliconSpreadsheet.SiliconSpreadsheetSheetListIt¶
Creates an iterator for the list.
- Returns
Returns the iterator.
- Return type
- 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.
- 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
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 returnsFalse
.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 returnsFalse
.
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 returnsFalse
.- Return type
bool
See also
hasPrevious()
andnext()
.
- 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 returnsFalse
.- Return type
bool
See also
hasNext()
andprevious()
.
- next() → Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet¶
- Returns
Returns the next item and advances the iterator by one position.
- Return type
See also
hasNext()
andprevious()
.
- previous() → Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet¶
- Returns
Returns the previous item and moves the iterator back by one position.
- Return type
See also
hasPrevious()
andnext()
.
- toBack() → None¶
Moves the iterator to the back of the container (after the last item).
See also
toFront()
andprevious()
.
- 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
See also
cellRange()
,cellName()
andSiliconSpreadsheetIndex
.
- 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()
andSiliconSpreadsheetIndex
.
- 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
See also
cellIndex()
andSiliconSpreadsheetIndex
.
- 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:
The type of value (e.g.,
SiliconSpreadsheetValueType_String
).The value as string.
- type¶
The type of value (e.g.,
SiliconSpreadsheetValueType_String
).See also
value
.
- 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:
Excel workspace type.
Unknown workspace type.
Methods:
addDefinedName
(name, formula)Adds a defined name to the workspace.
addSheet
(sheet)Adds a sheet to the workspace.
Returns a cell iterator for the workspace.
getCell
(idx[, curidx])Retrieves the value of a cell.
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.
Returns the list of sheets in the workspace.
Returns the type of workspace (e.g.,
WS_Excel
).Returns
True
if the workspace has defined names; otherwise returnsFalse
.
isCellValid
(idx[, curidx])Checks the presence of a cell.
Resets the modified status of the sheets.
setWorkspaceType
(type)Sets the type of the workspace.
Returns
True
if one of the sheets has been marked as modified; otherwise returnsFalse
.
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()
andsetWorkspaceType()
.
- WS_Unknown: Final[int]¶
Unknown workspace type.
See also
getWorkspaceType()
andsetWorkspaceType()
.
- 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()
andgetDefinedNames()
.
- addSheet(sheet: Pro.SiliconSpreadsheet.SiliconSpreadsheetSheet) → None¶
Adds a sheet to the workspace.
- Parameters
sheet (SiliconSpreadsheetSheet) – The sheet to add.
See also
getSheet()
,getSheets()
andSiliconSpreadsheetSheet
.
- cellIterator() → Pro.SiliconSpreadsheet.SiliconSpreadsheetCellIterator¶
- Returns
Returns a cell iterator for the workspace.
- Return type
See also
SiliconSpreadsheetCellIterator
.
- getCell(idx: Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex, curidx: Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex = SiliconSpreadsheetIndex()) → Pro.SiliconSpreadsheet.SiliconSpreadsheetCell¶
Retrieves the value of a cell.
- Parameters
idx (SiliconSpreadsheetIndex) – The index of the value to retrieve.
curidx (SiliconSpreadsheetIndex) – A reference index used to resolve a relative input index.
- Returns
Returns the cell value if successful; otherwise returns an invalid cell value.
- Return type
See also
SiliconSpreadsheetIndex
andSiliconSpreadsheetCell
.
- getDefinedNames() → Pro.Core.NTUTF8StringHash¶
- Returns
Returns a hash of defined names.
- Return type
See also
hasDefinedNames()
andaddDefinedName()
.
- 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
See also
SiliconSpreadsheetIndex
andSiliconSpreadsheetCellIndex
.
- 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
See also
addSheet()
,getSheets()
andSiliconSpreadsheetSheet
.
- getSheets() → Pro.SiliconSpreadsheet.SiliconSpreadsheetSheetList¶
- Returns
Returns the list of sheets in the workspace.
- Return type
See also
getSheet()
,addSheet()
andSiliconSpreadsheetSheet
.
- 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 returnsFalse
.- Return type
bool
See also
addDefinedName()
andgetDefinedNames()
.
- isCellValid(idx: Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex, curidx: Pro.SiliconSpreadsheet.SiliconSpreadsheetIndex = SiliconSpreadsheetIndex()) → bool¶
Checks the presence of a cell.
- Parameters
idx (SiliconSpreadsheetIndex) – The index of the cell to check.
curidx (SiliconSpreadsheetIndex) – A reference index used to resolve a relative input index.
- Returns
Returns
True
if the cell is present; otherwise returnsFalse
.- Return type
bool
See also
getCell()
andSiliconSpreadsheetIndex
.
- 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 returnsFalse
.- 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
See also
getSheet()
,sheetIndexFromName()
andSiliconSpreadsheetSheet
.
- 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()
andSiliconSpreadsheetSheet
.
- 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:
Returns the index of the current cell if available; otherwise returns an invalid index.
Returns the Excel emulator if available; otherwise returns
None
.Returns the spreadsheet workspace if available; otherwise returns an invalid workspace.
goToCell
(idx)Jumps to a specified cell.
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
See also
goToCell()
.
- getExcelEmulator() → Pro.SiliconSpreadsheet.SiliconExcelEmulator¶
- Returns
Returns the Excel emulator if available; otherwise returns
None
.- Return type
- getSpreadsheetWorkspace() → Pro.SiliconSpreadsheet.SiliconSpreadsheetWorkspace¶
- Returns
Returns the spreadsheet workspace if available; otherwise returns an invalid workspace.
- Return type
- 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
sdata (ScanViewData) – The scan view data.
w (SiliconSpreadsheetWorkspace) – The spreadsheet workspace.