SpreadsheetManager Class — NXOpen Python API Reference 12.0.0 documentation

# SpreadsheetManager Class

class `NXOpen.``SpreadsheetManager`

  Bases: `object`

  Represents a class for interacting with spreadsheets.

  There are different types of methods to use the APIs from this class.

  For interacting with the spreadsheet associated with a part file, use `Spreadsheet` object returned by `NXOpen.SpreadsheetManager.Open()` For interacting with external spreadsheet, use `Spreadsheet` object returned by `NXOpen.SpreadsheetManager.OpenFile()`. To obtain an instance of this class, refer to `NXOpen.Session`

  New in version NX11.0.0.

# Methods

Method | Description
--- | ---
CreateCellData | Creates SpreadsheetCellData object.
ExportFile | In NX/MGR mode, export an Excel spreadsheet file from the dataset file stored in the Teamcenter database to the native file system.
HorizontalLookup | Reads the value from a given spreadsheet using a horizontal table lookup.
Open | Opens excel sheet associated with given part file.
OpenFile | Opens an Excel spreadsheet file.
ReadAny | Reads value in a given cell, from a given spreadsheet.
ReadCell | Reads value in a given cell, from a given spreadsheet.
VerticalLookup | Reads the value from a given spreadsheet using a vertical table lookup.

# Enumerations

SpreadsheetManagerLookupMode Enumeration | Modes of lookup in the table.
SpreadsheetManagerOpenMode Enumeration | Sheet types to open spreadsheet.
SpreadsheetManagerSheettype Enumeration | Sheet types to open spreadsheet.

# Method Detail

## CreateCellData

`SpreadsheetManager.``CreateCellData`

  Creates SpreadsheetCellData object.

  Signature `CreateCellData()`

  Returns: | SpreadsheetCellData object.
  Return type: | `NXOpen.SpreadsheetCellData`

  New in version NX11.0.0.

  License requirements: None.

## ExportFile

`SpreadsheetManager.``ExportFile`

  In NX/MGR mode, export an Excel spreadsheet file from the dataset file stored in the Teamcenter database to the native file system.

  The file is exported for readnig only.

  Note: For dataset file stored in the Teamcenter database, the spreadsheet must be stored as a MSExcel or MSExcelX dataset. The dataset shall be attached to its containing item revision with an IMAN_specification relation. Up to one MSExcel or MSExcelX dataset can be attached.

  Signature `ExportFile(partnum)`

  Parameters: | partnum (str) – A part number containing a MsExcel dataset.
  Returns: | If the file is exported successfully, the function returns a string indicating

  the full file name in native file system. If the file failed to export, the function returns empty string indicating no native file available.

  In Native mode, it does nothing and always returns an empty string. :rtype: str

  New in version NX11.0.0.

  License requirements: None.

## HorizontalLookup

`SpreadsheetManager.``HorizontalLookup`

  Reads the value from a given spreadsheet using a horizontal table lookup.

  The Excel spreadsheet to be opened could be either from the native file system, or from the dataset file stored in the Teamcenter database.

  Note: The mode works when the target cell contains only numeric values and the mode is ignored when the target cell contains text

  Signature `HorizontalLookup(file, target, range, offset, mode)`

  Parameters:

  - file (str) – File name with full path
  - target (str) – Lookup target
  - range (str) – Table range
  - offset (int) – The offset to the data cell.
  - mode (`NXOpen.SpreadsheetManagerLookupMode`) – The mode of lookup in the table.

  Returns: | The calculated value in a spreadsheet cell as per the horizontal lookup
  Return type: | `NXOpen.SpreadsheetCellData`

  New in version NX11.0.0.

  License requirements: None.

## Open

`SpreadsheetManager.``Open`

  Opens excel sheet associated with given part file.

  And returns a `Spreadsheet` object.

  Signature `Open(sheettype, partfile)`

  Parameters:

  - sheettype (`NXOpen.SpreadsheetManagerSheettype`) – Sheet type
  - partfile (str) – Part file

  Returns: | Returns a `Spreadsheet` object to be used to access the spreadsheet.
  Return type: | `NXOpen.Spreadsheet`

  New in version NX11.0.0.

  License requirements: None.

## OpenFile

`SpreadsheetManager.``OpenFile`

  Opens an Excel spreadsheet file.

  The type of the access mode can be either Read, or Write. The Excel spreadsheet to be opened could be either from the native file system, or from the dataset file stored in the Teamcenter database.

  Note: For dataset file stored in the Teamcenter database, the spreadsheet must be stored as a MSExcel or MSExcelX dataset. The dataset shall be attached to its containing item revision with an IMAN_specification relation. Up to one MSExcel or MSExcelX dataset can be attached.

  Signature `OpenFile(sheet, mode)`

  Parameters:

  - sheet (str) – An external Excel file name
  - mode (`NXOpen.SpreadsheetManagerOpenMode`) – Mode read/write

  Returns: | Returns a `SpreadsheetExternal` object to be used to access the external spreadsheet.
  Return type: | `NXOpen.SpreadsheetExternal`

  New in version NX11.0.0.

  License requirements: None.

## ReadAny

`SpreadsheetManager.``ReadAny`

  Reads value in a given cell, from a given spreadsheet.

  The Excel spreadsheet to be opened could be either from the native file system, or from the dataset file stored in the Teamcenter database.

  Signature `ReadAny(filename, cell)`

  Parameters:

  - filename (str) – File name with full path
  - cell (str) – Cell number can contain the worksheet along with the cell number by separating the two fields with an exclamation mark. For example: Sheet1!A1

  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.

## ReadCell

`SpreadsheetManager.``ReadCell`

  Reads value in a given cell, from a given spreadsheet.

  The Excel spreadsheet to be opened could be either from the native file system, or from the dataset file stored in the Teamcenter database.

  Signature `ReadCell(filename, cell)`

  Parameters:

  - filename (str) – File name with full path
  - cell (str) – Cell number can contain the worksheet along with the cell number by separating the two fields with an exclamation mark. For example: Sheet1!A1

  Returns: | The numerical value in a spreadsheet cell.
  Return type: | `NXOpen.SpreadsheetCellData`

  New in version NX11.0.0.

  License requirements: None.

## VerticalLookup

`SpreadsheetManager.``VerticalLookup`

  Reads the value from a given spreadsheet using a vertical table lookup.

  The Excel spreadsheet to be opened could be either from the native file system, or from the dataset file stored in the Teamcenter database.

  Note: The mode works when the target cell contains only numeric values and the mode is ignored when the target cell contains text

  Signature `VerticalLookup(file, target, range, offset, mode)`

  Parameters:

  - file (str) – File name with full path
  - target (str) – Lookup target
  - range (str) – Table range
  - offset (int) – The offset to the data cell.
  - mode (`NXOpen.SpreadsheetManagerLookupMode`) – The mode of lookup in the table.

  Returns: | The calculated value in a spreadsheet cell as per the vertical lookup
  Return type: | `NXOpen.SpreadsheetCellData`

  New in version NX11.0.0.

  License requirements: None.