From b59d184021f596caf46a6e21ed9c80c8749b8a4a Mon Sep 17 00:00:00 2001 From: SolfaMode Date: Sat, 7 Mar 2026 13:45:04 +0100 Subject: [PATCH] Fix Relationship SchemaType decoding error. I could not read a file that was exported by Apple Numbers app due to a missing case in SchemaType. I see issues by other people having similar problems. So I made Relationship accept any string for rawType. Making type itself optional and a computed property fits well with the other use cases in this package. However, it might break other client's code. --- Sources/CoreXLSX/Relationships.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Sources/CoreXLSX/Relationships.swift b/Sources/CoreXLSX/Relationships.swift index 99efa2fe..e3add651 100644 --- a/Sources/CoreXLSX/Relationships.swift +++ b/Sources/CoreXLSX/Relationships.swift @@ -130,13 +130,29 @@ public struct Relationship: Codable, Equatable { """ http://purl.oclc.org/ooxml/officeDocument/relationships/extendedProperties """ + case sheetMetadata = + """ + http://schemas.openxmlformats.org/officeDocument/2006/relationships/\ + sheetMetadata + """ + } + + enum CodingKeys: String, CodingKey { + case id + case rawType = "type" + case target } /// The identifier for this entity. public let id: String /// The type of this entity. - public let type: SchemaType + public var type: SchemaType? { SchemaType(rawValue: rawType) } + + /// The raw type string. + /// This is needed so that Relationship decodes when encountering type strings + /// that are missing SchemaType cases. + public let rawType: String /// The path to this entity in the `.xlsx` archive. public let target: String