WorkbookKit is a minimal Swift library for reading and writing .xlsx (Excel) files. Built on top of ZIPFoundation.
- read .xlsx from local URL
- list sheets (name, id)
- read cells as Bool, Double, or String (Shared Strings and inline)
- detect merged ranges when reading
- create workbooks and sheets; write booleans, numbers, or text
- address cells via CellAddress or Excel-style coordinates ("A1", "B2") in the subscript API
- save valid .xlsx files that open in Excel and other spreadsheet apps
- writes only inline strings (no Shared Strings on write yet)
- no formulas (ignored on read, not written)
- only basic cell types; dates are not specially handled
- no styling (a minimal styles.xml is generated for validity)
- no charts/images/comments/pivot tables
- simple error handling; no lazy loading or async I/O
- you need to quickly extract or assemble a simple table;
- you want a predictable structure and minimal dependencies.
- you need formulas, styles, dates, images, large datasets, or high performance.
dependencies: [
.package(url: "https://github.com/hugonote/WorkbookKit.git", branch: "main")
]dependency: ZIPFoundation
you can also add it via the Xcode GUI.
import WorkbookKit
let workbook = Workbook()
workbook.addSheet(name: "Sheet1", id: 1)
workbook["Sheet1"]?["A1"] = .text("Hello!")
print(workbook["Sheet1"]?["A1"].asString()) // Hello!
workbook["Sheet1"]?["A2"] = .number(14)
let filePath: URL = URL(fileURLWithPath: "example.xlsx")
workbook.writeToFile(atPath: filePath)import WorkbookKit
let filePath: URL = URL(fileURLWithPath: "example.xlsx")
let workbook = Workbook(fromPath: filePath)
print(workbook["Sheet1"]?["A1"].asString()) // Hello!
let sheet = workbook["Sheet1"]
print(sheet?["A2"].asString()) // 14.0