Pkg.XLSX
— API for parsing Microsoft Excel XLSX files¶
Module API¶
Pkg.XLSX module API.
Classes:
This class represents an Excel XLSX file.
- class XLSXObject¶
Bases:
Pro.Zip.ZipObject
This class represents an Excel XLSX file.
Methods:
Creates a Silicon spreadsheet workspace that can be used for macro emulation.
Retrieves the [Content_Types].xml file from the XLSX package.
Retrieves all defined names in the workbook.
getFile
(name)Retrieves a file from the XLSX package.
Retrieves a mapping of relationship IDs to their target files within the XLSX package.
Retrieves the shared strings used in the workbook.
getSheetInfo
(rId)Retrieves information about a sheet given its relationship ID.
Retrieves information about all sheets in the workbook.
getTypes
()Retrieves a mapping of file names to their MIME content types within the XLSX package.
Retrieves the workbook XML file from the XLSX package.
Determines the path to the workbook file within the XLSX package.
Retrieves the relationships XML file associated with the workbook.
getXMLFile
(fname)Retrieves and parses an XML file from the XLSX package.
Parses an XML file from a given container.
- createSpreadsheetWorkspace() → Pro.SiliconSpreadsheet.SiliconSpreadsheetWorkspace¶
Creates a Silicon spreadsheet workspace that can be used for macro emulation.
- Returns
Returns the workspace.
- Return type
- getContentTypes() → Optional[Pro.Core.NTXml]¶
Retrieves the [Content_Types].xml file from the XLSX package.
- Returns
Returns an XML object if successful; otherwise returns
None
.- Return type
Optional[NTXml]
See also
getTypes()
.
- getDefinedNames() → List[Tuple[str, str]]¶
Retrieves all defined names in the workbook.
- Returns
Returns a list of tuples containing defined names and their associated references.
- Return type
List[Tuple[str, str]]
See also
getSharedStrings()
.
- getFile(name: str) → Pro.Core.NTContainer¶
Retrieves a file from the XLSX package.
- Parameters
name (str) – The name of the file within the XLSX package to retrieve.
- Returns
Returns a container for the specified file within the XLSX package.
- Return type
- getRelationships() → Dict[str, str]¶
Retrieves a mapping of relationship IDs to their target files within the XLSX package.
- Returns
Returns a dictionary mapping relationship IDs to their target file paths.
- Return type
Dict[str, str]
See also
getWorkbookRels()
.
Retrieves the shared strings used in the workbook.
- Returns
Returns a list of shared strings.
- Return type
List[str]
See also
getDefinedNames()
.
- getSheetInfo(rId: str) → Tuple[Optional[str], Optional[str]]¶
Retrieves information about a sheet given its relationship ID.
- Parameters
rId (str) – The relationship ID of the sheet.
- Returns
Returns a tuple containing the sheet type and path if successful; otherwise returns a tuple of
None
values.- Return type
Tuple[Optional[str], Optional[str]]
See also
getSheets()
.
- getSheets() → List[Dict[str, str]]¶
Retrieves information about all sheets in the workbook.
- Returns
Returns a list of dictionaries, each containing information about a sheet.
- Return type
List[Dict[str, str]]
See also
getSheetInfo()
.
- getTypes() → Dict[str, str]¶
Retrieves a mapping of file names to their MIME content types within the XLSX package.
- Returns
Returns a dictionary mapping file names to their MIME content types.
- Return type
Dict[str, str]
See also
getContentTypes()
.
- getWorkbook() → Optional[Pro.Core.NTXml]¶
Retrieves the workbook XML file from the XLSX package.
- Returns
Returns an XML object if successful; otherwise returns
None
.- Return type
Optional[NTXml]
See also
getWorkbookPath()
andgetWorkbookRels()
.
- getWorkbookPath() → Tuple[str, str, str]¶
Determines the path to the workbook file within the XLSX package.
- Returns
Returns a tuple containing the full workbook path, the directory path, and the workbook file name.
- Return type
Tuple[str, str, str]
See also
getWorkbook()
andgetWorkbookRels()
.
- getWorkbookRels() → Optional[Pro.Core.NTXml]¶
Retrieves the relationships XML file associated with the workbook.
- Returns
Returns an XML object if successful; otherwise returns
None
.- Return type
Optional[NTXml]
See also
getWorkbook()
.
- getXMLFile(fname: str) → Optional[Pro.Core.NTXml]¶
Retrieves and parses an XML file from the XLSX package.
- Parameters
fname (str) – The name of the XML file within the XLSX package to retrieve.
- Returns
Returns an XML object if successful; otherwise returns
None
.- Return type
Optional[NTXml]
- getXMLFromFile(c: Pro.Core.NTContainer) → Optional[Pro.Core.NTXml]¶
Parses an XML file from a given container.
- Parameters
c (NTContainer) – The container representing the file from which to extract XML content.
- Returns
Returns an XML object if successful; otherwise returns
None
.- Return type
Optional[NTXml]