As of 2018, Google has not yet added row / column visibility methods to the Sheets API. Now, at the end of 2018, they created an API for this.
This is sad, but I found another way:
When a row is the last visible, you cannot hide it (same with columns). Google Spreadsheet throws an error and shows you a message. Thus, when the script function hides every line except the one we want to check, in case of failure, our line is hidden. If the launch is successful, it means our row was visible.
Note that this workaround is too hacky to use in a performance sensitive script.
Examples of using:
var sheet = SpreadsheetApp.getActive().getActiveSheet()
The code
function isRowHidden (row, optionalSheet) { var ss = SpreadsheetApp.getActive() var sheet = optionalSheet || ss.getActiveSheet() SpreadsheetApp.setActiveSheet(sheet) var dup = ss.duplicateActiveSheet() SpreadsheetApp.setActiveSheet(sheet) var isHidden = false var rowIndex = row.getRow() var numRows = dup.getMaxRows() if (numRows === 1) { ss.deleteSheet(dup) return false } try { if (rowIndex === numRows ) { dup.hideRows(1, numRows - 1) } else if (rowIndex === 1) { dup.hideRows(rowIndex + 1, numRows - 1) } else { dup.hideRows(1, rowIndex - 1) dup.hideRows(rowIndex + 1, numRows - rowIndex) } isHidden = false } catch (e) { isHidden = true } finally { ss.deleteSheet(dup) } return isHidden } function isColumnHidden (col, optionalSheet) { var ss = SpreadsheetApp.getActive() var sheet = optionalSheet || ss.getActiveSheet() SpreadsheetApp.setActiveSheet(sheet) var dup = ss.duplicateActiveSheet() SpreadsheetApp.setActiveSheet(sheet) var isHidden = false var colIndex = col.getColumn() var numCols = dup.getMaxColumns() if (numCols === 1) { ss.deleteSheet(dup) return false } try { if (colIndex === numCols ) { dup.hideColumns(1, numCols - 1) } else if (colIndex === 1) { dup.hideColumns(colIndex + 1, numCols - 1) } else { dup.hideColumns(1, colIndex - 1) dup.hideColumns(colIndex + 1, numCols - colIndex) } isHidden = false } catch (e) { isHidden = true } finally { ss.deleteSheet(dup) } return isHidden } function isCellHidden (cell, optionalSheet) { var isHidden = isColumnHidden(cell, optionalSheet) || isRowHidden(cell, optionalSheet) return isHidden }
PS: Codex complies with JS standard.

eCorners
source share