Skip to content

rxcats/poi-kotlin-module

Repository files navigation

codecov License Maven Central Version

Apache POI Kotlin Module

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

Requirements

Java 17 and 21

Quickstart

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"))

About

Kotlin module for Apache POI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages