ExcelWeaverKotlin
A simple library for manipulate excel file in Kotlin.
basically, this is just another implementation version of ExcelWeaver.
TL;DR
*.xlsx
→ List
List
→ *.xlsx
To build
./gradlew shadowJar
(And Jar will be found in build/libs
)
To Use
Make definition of sheet
@Sheet(dataStartIndex = 2)
data class Contract (// Class name will be sheets name
@Column(position = "B")
val name: String,
@Column(position = "C")
val cellPhone: String,
@Column(position = "D")
val postCode: Int
)
Make definition of book
// Create from array or list of SheetDef classes
val bookDef = BookDef.of(Contract::class.java, Message::class.java);
// add more sheet
bookDef.addSheet(Salary::class.java);
Read file
val list: List<Contract>
bookDef.openBook(outputPath).use { list = it.read(Contract::class.java) }
Write file
val list = createData()
bookDef.openBook(templatePath, outputPath).use { it.write(list) }