Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workbook parsing error #185

Open
brad-w opened this issue Jan 28, 2025 · 0 comments
Open

Workbook parsing error #185

brad-w opened this issue Jan 28, 2025 · 0 comments
Assignees

Comments

@brad-w
Copy link

brad-w commented Jan 28, 2025

Version

0.14.2

Description of the bug

Unable to parse file with parseWorkbooks() decoding error

Code

import CoreXLSX

let filepath = "./Res_Inclu_TOU_Current.xlsx"
guard let file = XLSXFile(filepath: filepath) else {
  fatalError("XLSX file at \(filepath) is corrupted or does not exist")
}

for wbk in try file.parseWorkbooks() {
  for (name, path) in try file.parseWorksheetPathsAndNames(workbook: wbk) {
    if let worksheetName = name {
      print("This worksheet has a name: \(worksheetName)")
    }

    let worksheet = try file.parseWorksheet(at: path)
    for row in worksheet.data?.rows ?? [] {
      for c in row.cells {
        print(c)
      }
    }
  }
}

File for reproduction

Res_Inclu_TOU_Current.xlsx

Additional context

I had this working for a few years, but I guess something in the energy company's xlsx file generation changed.

Output
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "relationship", intValue: nil), XMLKey(stringValue: "1", intValue: 1), XMLKey(stringValue: "1", intValue: 1), CodingKeys(stringValue: "type", intValue: nil)], debugDescription: "Cannot initialize SchemaType from invalid String value http://schemas.microsoft.com/office/2020/02/relationships/classificationlabels", underlyingError: nil))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants