live to contemplate, be aware, and take action

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.

One response to “Parse Excel with Kotlin”

  1. Nice post man, it really helped me, thanks for sharing!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Website Powered by

%d bloggers like this: