-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add the state
property to Sheet
.
#177
base: main
Are you sure you want to change the base?
Conversation
Sources/CoreXLSX/Workbook.swift
Outdated
@@ -45,11 +45,13 @@ public struct Workbook: Codable, Equatable { | |||
public let name: String? | |||
public let id: String | |||
public let relationship: String | |||
public let state: String? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In contrast to name
, id
and relationship
- state
seems to me more fit to be an enum
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.