Add the state property to Sheet.#177
Conversation
Sources/CoreXLSX/Workbook.swift
Outdated
| public let name: String? | ||
| public let id: String | ||
| public let relationship: String | ||
| public let state: String? |
There was a problem hiding this comment.
In contrast to name, id and relationship - state seems to me more fit to be an enum.
There was a problem hiding this comment.
Also, please (re-)mark me for review so that I see it in my list of open PRs to review when you're ready
There was a problem hiding this comment.
Sure, I didn't use an enum because I've no idea what are the possible values. I've seen "visible", "hidden", and "veryHidden" XD
I guess people can add if they know about other states.
There was a problem hiding this comment.
If we don't know the exhaustive list of states, let's do a struct similar to this instead:
public struct State: RawRepresentable, Codable {
public var rawValue: String
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(rawValue)
}
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
self.rawValue = try container.decode(String.self)
}
public static let visible = State(rawValue: "visible")
public static let hidden = State(rawValue: "hidden")
public static let veryHidden = State(rawValue: "veryHidden")
}There was a problem hiding this comment.
Please tag me again when you have a reply/updated the code. Sorry about the ping-ponging, but if we don't know the exhaustive list of cases, we cannot use an enum at this stage. Swift doesn't allow libraries to have unknown future cases using @unknown default:
This adds the possibility to check the state of the worksheet. In particular it allows seeing whether the sheet is hidden or visible.