Android (Java/Kotlin) Google Sheets API: Check if Sheet Is Empty

April 21, 2019
private fun isSheetEmpty(service: Sheets, spreadsheetId: String, sheetName: String): Boolean {
    val result = service.spreadsheets().values().get(spreadsheetId, "'$sheetName'").execute()
    return result.getValues() == null || result.getValues().size == 0
}

NOTE: service is Sheets. Refer to Get Google Sheets service instance.

NOTE: Refer to Get Sheet Name.

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.