Parse Excel with Kotlin

I want to share how to parse excel files using kotlin and apache poi java lib. repository can be found here.

This example will parse a sheet with several cell type (number, string, date). The basic ideas are:
1. get the Workbook instance by instantiating XSSFWorkbook(file: File)
2. get the Sheet instance by call workbook.getSheetAt(idx: Int) or workbook.getSheet(sheetName: String)
3. traverse every rows in the sheet by call sheet.getRow(idx: Int)
4. traverse every columns in the row.

Spread the love

One comment

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to Top