title: How do I determine if a column is hidden in Google Spreadsheet using scripts?
body: <p>I'm trying to write a function for Google Spreadsheet that locates the first and last column of a group. It then hides the group, or shows it if it's already hidden.</p>
  
  <p>However, I haven't been able to find a way to determine whether a column is hidden or not. I haven't been able to find anything anything on Google's Class Sheet page <a href="https://developers.google.com/apps-script/reference/spreadsheet/sheet" rel="noreferrer">https://developers.google.com/apps-script/reference/spreadsheet/sheet</a>, and I haven't found an equivalent to Excel's .hidden</p>
  
  <p>getColumnWidth(column) returns the unhidden column width even when it's hidden.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>function hideShowColumns(startCol, endCol) { 
    //endCol is one column past the last data set that should be hidden
    var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Transposed Data");
    //import the data from the Column Headers
    var colHeaderData = sheet.getRange(1, 1, 2, sheet.getMaxColumns()).getValues(); 
    var startColNum = 0;
    var endColNum = 0;
  
    // This section searches for the column names in the header rows and returns their column number
    for (var i =0; i &lt; 2; ++i) {
      for (var j = 0; j &lt; colHeaderData[0].length; ++j) {
        if (colHeaderData[i][j] == startCol) 
          startColNum = j;
        if (colHeaderData[i][j] == endCol) 
          endColNum = j;
      }
    }
  
    //This is the wrong command getColumnWidth doesn't change if column is hidden
    if (sheet.getColumnWidth(startColNum + 1) != 0) {
      sheet.hideColumns(startColNum + 2, endColNum - startColNum - 1);
      Logger.log(sheet.getColumnWidth(startColNum + 2));
      return;
    }
  
    //This is the wrong command getColumnWidth doesn't change if column is hidden
    if (sheet.getColumnWidth(startColNum + 1) == 0) { 
      for (var j = startColNum + 1; j &lt; endColNum - 1; ++j) {
        sheet.unhideColumn(j);
        Logger.log(sheet.getColumnWidth(startColNum + 2));     
      }
      return;
    }
  }
  </code></pre>
  
  <p>Thanks for the help!</p>