Kexcel — Excel (.xlsx) for Kotlin Multiplatform¶
Kexcel is a Kotlin Multiplatform library for reading and writing Excel
spreadsheets (.xlsx, the Office Open XML format) — written in pure Kotlin,
with no platform-specific dependencies.
Because it doesn't wrap Apache POI — or any other JVM library — the same
spreadsheet code compiles and runs on JVM, Android and iOS. That makes it a
practical Apache POI alternative for Kotlin Multiplatform (KMP/KMM) and
Compose Multiplatform apps, which otherwise have no way to touch .xlsx files
outside the JVM.
Kexcel is a Kotlin port of the Dart excel
library by justkawal.
Experimental
Kexcel is under active development. The API is unstable and may change
without notice between 0.0.x releases.
Why Kexcel?¶
-
Pure Kotlin
No POI, no JVM-only APIs. The same code runs on every supported target.
-
Truly multiplatform
JVM, Android and iOS (
iosArm64,iosSimulatorArm64) are published today. -
A small, focused API
One entry point —
Excel— and a handful of value and style types. Read a file, mutate it, write it back. -
In-memory round-trips
encode()turns a workbook into.xlsxbytes with no filesystem access, which is handy on every platform.
Supported targets¶
| Target | Status |
|---|---|
| JVM | ✅ Published |
Android (minSdk 23) |
✅ Published |
iOS (iosArm64, iosSimulatorArm64) |
✅ Published |
wasmJs, macosArm64 |
🧪 Build targets present, not yet published |
| JS, Linux, MinGW | ⚙️ Commented out in the build |
A 30-second taste¶
import com.gyanoba.kexcel.Excel
import com.gyanoba.kexcel.sheet.CellIndex
import com.gyanoba.kexcel.sheet.TextCellValue
import com.gyanoba.kexcel.sheet.IntCellValue
// Create a blank workbook (it starts with a single sheet, "Sheet1").
val excel = Excel.createExcel()
val sheet = excel["Sheet1"]
// Write a couple of cells.
sheet.updateCell(CellIndex.indexByString("A1"), TextCellValue("Hello"))
sheet.updateCell(CellIndex.indexByString("B1"), IntCellValue(42))
// Serialize to .xlsx bytes (entirely in memory).
val bytes: ByteArray? = excel.encode()
Where next?¶
- Installation — add the dependency to your Gradle build.
- Quick Start — create, edit and save a workbook end to end.
- Guides — task-focused walkthroughs of every part of the API.
- API Reference — the full generated Dokka reference.
Frequently asked questions¶
Does Kexcel use Apache POI?¶
No. Kexcel is written in pure Kotlin and depends only on multiplatform libraries
(kmp-zip for the ZIP container and
Ksoup for XML). That is precisely why it
runs outside the JVM — Apache POI, and every Kotlin wrapper built on it, is
JVM-only.
Can I read and write Excel files on Android and iOS?¶
Yes. JVM, Android and iOS (iosArm64, iosSimulatorArm64) are published
targets, so the same commonMain code works on all of them — including in a
Compose Multiplatform app.
Which file formats are supported?¶
.xlsx (Office Open XML) only — the format Excel 2007 and later, Google Sheets,
Numbers and LibreOffice all write. The legacy binary .xls format is not
supported.
Can it do styling, formulas and merged cells?¶
Yes — see Cell Styling, Formulas and Merging Cells. Number formats, column widths, row heights and find-and-replace are covered in the guides too.
Does it need the filesystem?¶
No. encode() returns the workbook as a ByteArray, so you
can round-trip a spreadsheet entirely in memory and hand the bytes to whatever
storage, network or file API your platform provides.
License¶
Kexcel is released under the MIT License.