Spreadsheet Class

class NXOpen.Spreadsheet

Bases: NXOpen.TransientObject

Represents a class for internal spreadsheet.

To call functions from this class, use Spreadsheet object returned by NXOpen.SpreadsheetManager.Open(). .. Usable only on Windows

New in version NX11.0.0.

Methods

Method Description
Clear Clears the contents of the current worksheet.
Delete Deletes (clears) one or more rows/columns of data from a worksheet.
DeleteSheets Deletes specified number of sheets beginning with the specified sheet (from the current worksheet, if no sheet is specified).
Dispose Free resources associated with the instance.
EraseRange Clears the contents of the specified range
EvaluateCell Returns the evaluated value of a cell.
GetFormula Retrieves a formula from a cell.
GetNamedRange Resolves the named reference and returns the range of cells that are named This method returns a list, of the following format: Start Row, Start Column, End Row, End Column, Start Sheet Number, End Sheet Number of the named reference.
GetNumber Retrieves a numeric value from a cell.
GetNumberOfSheets Returns the total number of sheets in the spreadsheet
GetSheetNames Returns list of existing sheet names in the spreadsheet.
GetSheetNumber Returns the current work sheet number of the spreadsheet.
GetSheetNumberOfName Returns sheet number of the sheet with given name.
GetString Returns the String in the cell
GetValue Returns a number, string or formula depending on the contents of the cell.
InsertSheets Inserts specified number of sheets before the specified sheet (or the current work sheet if no sheet is specified).
Recalculate Recalculates the spreadsheet.
Save Saves the spreadsheet in the part file.
SetFormula Stores a formula into a cell.
SetNamedRange Defines a name for the Range of cells.
SetNumber Stores a numeric value in the specified cell of the worksheet.
SetSheetNumber Sets the worksheet with specified index as current worksheet
SetString Sets the string in the cell.
Terminate Terminates excel sheet for opened part.

Method Detail

Clear

Spreadsheet.Clear

Clears the contents of the current worksheet.

Signature Clear()

New in version NX11.0.0.

License requirements: None.

Delete

Spreadsheet.Delete

Deletes (clears) one or more rows/columns of data from a worksheet.

Signature Delete(start1, end1, sheet, operation)

Parameters:
  • start1 (int) – From where the deletion should start
  • end1 (int) – Upto where the rows should be deleted
  • sheet (int) – The sheet in which deletion should take place.(Current sheet, if no sheet is specified)
  • operation (int) – 1 for row deletion and 2 for column deletion.

New in version NX11.0.0.

License requirements: None.

DeleteSheets

Spreadsheet.DeleteSheets

Deletes specified number of sheets beginning with the specified sheet (from the current worksheet, if no sheet is specified).

Signature DeleteSheets(sheet, count)

Parameters:
  • sheet (int) – Sheet Number, starting from which sheets are to be deleted.
  • count (int) – Number of sheets to be deleted

New in version NX11.0.0.

License requirements: None.

Dispose

Spreadsheet.Dispose

Free resources associated with the instance.

After this method is called, it is illegal to use the object. In .NET, this method is automatically called when the object is deleted by the garbage collector.

Signature Dispose()

New in version NX11.0.0.

License requirements: None.

EraseRange

Spreadsheet.EraseRange

Clears the contents of the specified range

Signature EraseRange(row0, col0, row1, col1, sheet0, sheet1)

Parameters:
  • row0 (int) – Starting row for range
  • col0 (int) – Starting column for range
  • row1 (int) – Ending row for range
  • col1 (int) – Ending column for range
  • sheet0 (int) – Sheet number for start of the range
  • sheet1 (int) – Sheet number for end of the range

New in version NX11.0.0.

License requirements: None.

EvaluateCell

Spreadsheet.EvaluateCell

Returns the evaluated value of a cell.

Signature EvaluateCell(row, col, sheet)

Parameters:
  • row (int) – Row index of the cell
  • col (int) – Column index of the cell
  • sheet (int) – Sheet index (current worksheet, if zero is specified).
Returns:

The value in a spreadsheet cell as either a string or a number

Return type:

NXOpen.SpreadsheetCellData

New in version NX11.0.0.

License requirements: None.

GetFormula

Spreadsheet.GetFormula

Retrieves a formula from a cell.

Signature GetFormula(row, col, sheet)

Parameters:
  • row (int) – Row index of the cell
  • col (int) – Column index of the cell
  • sheet (int) – Sheet index (current worksheet, if zero is specified)
Returns:

Retrieves a formula from a cell.

Return type:

NXOpen.SpreadsheetCellData

New in version NX11.0.0.

License requirements: None.

GetNamedRange

Spreadsheet.GetNamedRange

Resolves the named reference and returns the range of cells that are named This method returns a list, of the following format: Start Row, Start Column, End Row, End Column, Start Sheet Number, End Sheet Number of the named reference.

Signature GetNamedRange(rangename)

Parameters:rangename (str) – Range name
Returns:The range of cells for given range name
Return type:list of int

New in version NX11.0.0.

License requirements: None.

GetNumber

Spreadsheet.GetNumber

Retrieves a numeric value from a cell.

Signature GetNumber(row, col, sheet)

Parameters:
  • row (int) – Row index of the cell
  • col (int) – Column index of the cell
  • sheet (int) – Sheet index (current worksheet, if zero is specified)
Returns:

Retrieves a numerical value from a cell

Return type:

NXOpen.SpreadsheetCellData

New in version NX11.0.0.

License requirements: None.

GetNumberOfSheets

Spreadsheet.GetNumberOfSheets

Returns the total number of sheets in the spreadsheet

Signature GetNumberOfSheets()

Returns:Number of sheets in the spreadsheet
Return type:int

New in version NX11.0.0.

License requirements: None.

GetSheetNames

Spreadsheet.GetSheetNames

Returns list of existing sheet names in the spreadsheet.

Signature GetSheetNames()

Returns:List of sheet names from specified spreadsheet
Return type:list of str

New in version NX11.0.0.

License requirements: None.

GetSheetNumber

Spreadsheet.GetSheetNumber

Returns the current work sheet number of the spreadsheet.

Signature GetSheetNumber()

Returns:Current work sheet number of the spreadsheet.
Return type:int

New in version NX11.0.0.

License requirements: None.

GetSheetNumberOfName

Spreadsheet.GetSheetNumberOfName

Returns sheet number of the sheet with given name.

Signature GetSheetNumberOfName(sheetname)

Parameters:sheetname (str) – Sheet name
Returns:Work sheet number of the given spreadsheet name.
Return type:int

New in version NX11.0.0.

License requirements: None.

GetString

Spreadsheet.GetString

Returns the String in the cell

Signature GetString(row, col, sheet)

Parameters:
  • row (int) – Row index of the cell
  • col (int) – Column index of the cell
  • sheet (int) – Sheet index of the cell (current worksheet, if zero is specified).
Returns:

Retrieves a string value from a cell

Return type:

NXOpen.SpreadsheetCellData

New in version NX11.0.0.

License requirements: None.

GetValue

Spreadsheet.GetValue

Returns a number, string or formula depending on the contents of the cell.

Signature GetValue(row, col, sheet)

Parameters:
  • row (int) – Row index of the cell
  • col (int) – Column index of the cell
  • sheet (int) – Sheet index of the cell (current worksheet, if zero is specified).
Returns:

The value in a spreadsheet cell as either a string or a number

Return type:

NXOpen.SpreadsheetCellData

New in version NX11.0.0.

License requirements: None.

InsertSheets

Spreadsheet.InsertSheets

Inserts specified number of sheets before the specified sheet (or the current work sheet if no sheet is specified).

Signature InsertSheets(sheet, count)

Parameters:
  • sheet (int) – Sheet number, before which the sheets are to be inserted.
  • count (int) – Number of sheets to be inserted.

New in version NX11.0.0.

License requirements: None.

Recalculate

Spreadsheet.Recalculate

Recalculates the spreadsheet.

Signature Recalculate()

New in version NX11.0.0.

License requirements: None.

Save

Spreadsheet.Save

Saves the spreadsheet in the part file.

Signature Save()

New in version NX11.0.0.

License requirements: None.

SetFormula

Spreadsheet.SetFormula

Stores a formula into a cell.

Signature SetFormula(row, col, cellvalue, sheet)

Parameters:
  • row (int) – Row index of the cell
  • col (int) – Column index of the cell
  • cellvalue (NXOpen.SpreadsheetCellData) –
  • sheet (int) – Sheet index of the cell (current worksheet, if zero is specified).

New in version NX11.0.0.

License requirements: None.

SetNamedRange

Spreadsheet.SetNamedRange

Defines a name for the Range of cells.

Signature SetNamedRange(rangename, row0, col0, row1, col1, sheet)

Parameters:
  • rangename (str) – Name to be given to the range
  • row0 (int) – Starting row of the table, which is being named
  • col0 (int) – Starting column of the table, which is being named
  • row1 (int) – Row of the table, upto which the name will apply
  • col1 (int) – Column of the table, upto which the name will apply
  • sheet (int) – Sheet index of the table (current worksheet, if zero is specified).

New in version NX11.0.0.

License requirements: None.

SetNumber

Spreadsheet.SetNumber

Stores a numeric value in the specified cell of the worksheet.

Signature SetNumber(row, col, cellvalue, sheet)

Parameters:
  • row (int) – Row index of the cell
  • col (int) – Column index of the cell
  • cellvalue (NXOpen.SpreadsheetCellData) – Numeric value to be set in the cell.
  • sheet (int) – Sheet index (current worksheet, if zero is specified).

New in version NX11.0.0.

License requirements: None.

SetSheetNumber

Spreadsheet.SetSheetNumber

Sets the worksheet with specified index as current worksheet

Signature SetSheetNumber(sheet)

Parameters:sheet (int) – The number to which the current work sheet is to be set.

New in version NX11.0.0.

License requirements: None.

SetString

Spreadsheet.SetString

Sets the string in the cell.

Signature SetString(row, col, cellvalue, sheet)

Parameters:
  • row (int) – Row index of the cell.
  • col (int) – Column index of the cell.
  • cellvalue (NXOpen.SpreadsheetCellData) – String to be stored in this cell.
  • sheet (int) – Sheet index (current worksheet, if zero is specified).

New in version NX11.0.0.

License requirements: None.

Terminate

Spreadsheet.Terminate

Terminates excel sheet for opened part.

Signature Terminate()

New in version NX11.0.0.

License requirements: None.