Skip to content

Instantly share code, notes, and snippets.

@ciferkey
Created October 14, 2018 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciferkey/393fec4083f9c68a8233257ad34c7a18 to your computer and use it in GitHub Desktop.
Save ciferkey/393fec4083f9c68a8233257ad34c7a18 to your computer and use it in GitHub Desktop.
fun Sheet.row(rowNumber: Int? = null, block: Row.() -> Unit): Row {
return createRow(rowNumber ?: physicalNumberOfRows).apply(block)
}
fun Row.cell(value: Any? = null, column: Int? = null, block: Cell.() -> Unit = {}): Cell {
val cell = createCell(column ?: physicalNumberOfCells)
when (value) {
is Calendar -> cell.setCellValue(value)
is Date -> cell.setCellValue(value)
is Boolean -> cell.setCellValue(value)
is Double -> cell.setCellValue(value)
is String -> cell.setCellValue(value)
is RichTextString -> cell.setCellValue(value)
}
return cell.apply(block)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment