问题描述
我正在使用dataTable
是否可以将导出文件名设置为所有文件格式(使用一个命令),还是我必须对每个按钮执行此操作?
如果是的话-如何将其设置为csv,excel和pdf?
struct City: Codable {
let zipCode: Int
let latitude,longitude: Itude
let city: String
let state: State
let county: String
enum CodingKeys: String,CodingKey {
case zipCode = "zip_code"
case latitude,longitude,city,state,county
}
}
enum Itude: Codable {
case double(Double)
case string(String)
init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if let x = try? container.decode(Double.self) {
self = .double(x)
return
}
if let x = try? container.decode(String.self) {
self = .string(x)
return
}
throw DecodingError.typeMismatch(Itude.self,DecodingError.Context(codingPath: decoder.codingPath,debugDescription: "Wrong type for Itude"))
}
func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case .double(let x):
try container.encode(x)
case .string(let x):
try container.encode(x)
}
}
}
enum State: String,Codable {
case aa = "AA"
case ae = "AE"
case ak = "AK"
case al = "AL"
case ap = "AP"
case ar = "AR"
case az = "AZ"
case ca = "CA"
case co = "CO"
case ct = "CT"
case dc = "DC"
case de = "DE"
case fl = "FL"
case fm = "FM"
case ga = "GA"
case gu = "GU"
case hi = "HI"
case ia = "IA"
case id = "ID"
case il = "IL"
case ks = "KS"
case ky = "KY"
case la = "LA"
case ma = "MA"
case md = "MD"
case me = "ME"
case mh = "MH"
case mi = "MI"
case mn = "MN"
case mo = "MO"
case mp = "MP"
case ms = "MS"
case mt = "MT"
case nc = "NC"
case nd = "ND"
case ne = "NE"
case nh = "NH"
case nj = "NJ"
case nm = "NM"
case nv = "NV"
case ny = "NY"
case oh = "OH"
case ok = "OK"
case or = "OR"
case pa = "PA"
case pr = "PR"
case pw = "PW"
case ri = "RI"
case sc = "SC"
case sd = "SD"
case stateAS = "AS"
case stateIN = "IN"
case tn = "TN"
case tx = "TX"
case ut = "UT"
case va = "VA"
case vi = "VI"
case vt = "VT"
case wa = "WA"
case wi = "WI"
case wv = "WV"
case wy = "WY"
}
typealias Cities = [City]
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)