CoreXLSX Documentation Beta

Class XLSXFile

public class XLSXFile

The entry point class that represents an open file handle to an existing .xlsx file on the user's filesystem.

Initializers

init?(filepath:​buffer​Size:​error​Context​Length:​)

public init?(filepath: String, bufferSize: UInt32 = 10 * 1024 * 1024, errorContextLength: UInt = 0)

Parameters

filepath String

path to the .xlsx file to be processed.

buffer​Size UInt32

ZIP archive buffer size in bytes. The default is 10MB. You may need to set a bigger buffer size for bigger files.

error​Context​Length UInt

The error context length. The default is 0. Non-zero length makes an error thrown from the XML parser with line/column location repackaged with a context around that location of specified length. For example, if an error was thrown indicating that there's an unexpected character at line 3, column 15 with errorContextLength set to 10, a new error type is rethrown containing 5 characters before column 15 and 5 characters after, all on line 3. Line wrapping should be handled correctly too as the context can span more than a few lines.

init(data:​buffer​Size:​error​Context​Length:​)

public init(data: Data, bufferSize: UInt32 = 10 * 1024 * 1024, errorContextLength: UInt = 0) throws

Parameters

data Data

content of the .xlsx file to be processed.

buffer​Size UInt32

ZIP archive buffer size in bytes. The default is 10MB. You may need to set a bigger buffer size for bigger files.

error​Context​Length UInt

The error context length. The default is 0. Non-zero length makes an error thrown from the XML parser with line/column location repackaged with a context around that location of specified length.

Methods

parse​Relationships()

public func parseRelationships() throws -> Relationships

parse​Document​Paths()

public func parseDocumentPaths() throws -> [String]

Return an array of paths to relationships of type officeDocument

parse​Styles()

public func parseStyles() throws -> Styles

parse​Shared​Strings()

public func parseSharedStrings() throws -> SharedStrings?

parse​Comments(for​Worksheet:​)

public func parseComments(forWorksheet path: String) throws -> Comments

parse​Workbooks()

public func parseWorkbooks() throws -> [Workbook]

Parse and return an array of workbooks in this file. Worksheet names can be read as properties on the Workbook model type.

parse​Document​Relationships()

@available(*, deprecated, renamed: "parseDocumentRelationships(path:)") public func parseDocumentRelationships() throws -> [([Substring], Relationships)]

Return pairs of parsed document paths with corresponding relationships.

Deprecation warning: this function doesn't handle root paths correctly, even though some XLSX files do contain root paths instead of relative paths. Use parseDocumentRelationships(path:) instead.

parse​Document​Relationships(path:​)

public func parseDocumentRelationships(path: String) throws -> (Path, Relationships)

Return parsed path with a parsed relationships model for a document at given path. Use parseDocumentPaths first to get a string path to pass as an argument to this function.

parse​Worksheet​Paths​And​Names(workbook:​)

public func parseWorksheetPathsAndNames(workbook: Workbook) throws -> [(name: String?, path: String)]

Parse and return an array of worksheets in this XLSX file with their corresponding names.

parse​Worksheet​Paths()

public func parseWorksheetPaths() throws -> [String]

Parse and return an array of worksheets in this XLSX file.

parse​Worksheet(at:​)

public func parseWorksheet(at path: String) throws -> Worksheet

Parse a worksheet at a given path contained in this XLSX file.

cells​InWorksheet(at:​rows:​)

@available(*, deprecated, renamed: "Worksheet.cells(atRows:)") public func cellsInWorksheet(at path: String, rows: [Int]) throws -> [Cell]

Return all cells that are contained in a given worksheet and set of rows.

cells​InWorksheet(at:​columns:​)

@available(*, deprecated, renamed: "Worksheet.cells(atColumns:)") public func cellsInWorksheet(at path: String, columns: [String]) throws -> [Cell]

Return all cells that are contained in a given worksheet and set of columns. This overloaded version is deprecated, you should pass an array of ColumnReference values as columns instead of an array of Strings.