title: Enable data filters on a range with Google Apps Script
body: <p>Is there a way to enable data filters by script in a Google Sheet for a certain range? Currently this can be doen manually, but I do not want to select a range, then click 'Data', and then turn on filter.</p>
  
  <p>I know that the filter will remain in an existing sheet. However, I try to apply a filter for a new spreadsheet that is generated via scripting.</p>
  
  <p>My idea is:</p>
  
  <pre><code>function foo() {
    var spreadsheet = SpreadsheetApp.getActive();
    var infoSheet = spreadsheet.insertSheet('sheetName', spreadsheet.getNumSheets());
  
    infoSheet.getRange(1, 1, 5, 5). -&gt; enable filter?
    ...
  }
  </code></pre>
  
  <p>How can I achieve my goal programmatically?</p>