Kotlin module for Apache POI
- You can use the kotlin data classes to convert to excel.
- properties can be immutable; i.e. val is allowed
Java 17 and 21
Mapping and convert to excel bytes
@ExcelSheet("Sheet1") // sheet name annotation
data class ItemTable(
@ExcelCellOrder(10) // column order annotation
@ExcelCellHeader("Id") // column name annotation
val id: Int,
@ExcelCellOrder(20)
@ExcelCellHeader("Name")
val name: String,
@ExcelCellOrder(30)
@ExcelCellHeader("ItemType")
val itemType: String,
@ExcelCellOrder(40)
@ExcelCellHeader("Price")
val price: Long,
@ExcelCellOrder(50)
@ExcelCellHeader("Description")
val description: String,
)
// create data and export to bytes
val bytes = excelExport(listOf(ItemTable(
id = TODO(),
name = TODO(),
itemType = TODO(),
price = TODO(),
description = TODO()
)))
// import file
val list = excelImport<ItemTable>(File("filename.xlsx"))