Skip to content

nwillc/poink

Repository files navigation

Coverage license Build Status Download

Poink!

POI iN Kotlin

A Kotlin DSL to read/write XLSX files via Apache POI.

Really almost nothing here, the DSL is a facade for Apache POI, providing for somewhat simpler use.

Generating

        workbook {
            // Create a named cell style
            val headerStyle = cellStyle("Header") {
                fillForegroundColor = IndexedColors.GREY_25_PERCENT.index
                fillPattern = FillPatternType.SOLID_FOREGROUND
            }
            sheet("One") {
                // Add a row with a style
                row(listOf("a", "b", "c"), headerStyle)
                // Add a row without style
                row(listOf(1, 2.0, 3L))
            }
            sheet {
                row(listOf("A very wide cell"))
                row(listOf("An even wider column"))
                // Auto size the width of a column
                autoSizeColumn(0)
            }
        }.write("test.xlsx")

Reading

   workbook("test.xlsx") {
            sheet("One") {
               iterator().forEach { row ->
                    row.iterator().forEach { cell ->
                        println(cell.stringCellValue)
                    }
               }
            }
        }

See Also

About

Apache POI Kotlin DSL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages