Skip to content

Latest commit

 

History

History
59 lines (41 loc) · 1.83 KB

README.en.md

File metadata and controls

59 lines (41 loc) · 1.83 KB

KExcelAPI Build Status Coverage Status

It is a wrapper of Apache POI for Kotlin. I am thinking of making everyone love Excel as easy as possible.

This library has been created under the influence of GExcelAPI.

How to use

From the sheet you can retrieve the Cell object by specifying the cell name or cell index.

Since we need a type to retrieve the data from the cell object, we will get the value with methods like toInt, toDouble, toStr etc.

In the case of a set of data, the type is obvious, so you can set the value on Excel with "=".

As a basic method of use, we import the link.webarata3.kexcelapi. * Package because we are using extension functions.

import link.webarata3.kexcelapi.*

Preparation is complete by this alone. You can now access Excel as follows.

// Easy file open, close
KExcel.open("file/book1.xlsx").use { workbook ->
    val sheet = workbook[0]

    // Cell loading
    // Access by Cell name
    println("""B7=${sheet["B7"].toStr()}""")
    // Access by Cell index [x, y]
    println("B7=${sheet[1, 6].toDouble()}")
    println("B7=${sheet[1, 6].toInt()}")

    // Write Cell
    sheet["A1"] = "あいうえお" // Japanese
    sheet[3, 7] = 123

    // Easy to write files
    KExcel.write(workbook, "file/book2.xlsx")
}

Maven

The Maven repository (Gradle setting) is as follows.

repositories {
    maven { url 'https://raw.githubusercontent.com/webarata3/maven/master/repository' }
}

dependencies {
    compile 'link.webarata3.kexcelapi:kexcelapi:0.5.0'
}

License

MIT