1
votes

I want to remove the filtration from the spreadsheet using a script and after i remove filtered rows the sheet display all row in sheet

I want to do that when I open the spreardsheet.

function ShowColumns() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  var maxRows = sheet.getMaxRows();
  var maxCol  = sheet.getMaxColumns();
  sheet.showRows(1, maxRows);
  sheet.showColumns(1,maxCol)
}

I searched for it intensively, but did't find anything.

1
any help please, i try but i can not do itAhmed Gomaa
The code you used was referencing rows and columns.....Therefore my solution.Jacob Jan Tuinstra
why no body help me :(Ahmed Gomaa
Hi Ahmed, I flagged your post as a duplicate. See the issue mentioned in the other post, as an explanation as to why it doesn't work.Jacob Jan Tuinstra

1 Answers

0
votes

There is a way to do it with Google advanced service - Google Sheets API. And here is my function to turn off the filter in Google Sheet.

function removeFilter(sheet){
  var ss = SpreadsheetApp.getActive();
  var spreadsheetId = ss.getId();
  var sheetId = sheet.getSheetId();
  var resource = {
                    "requests": [
                      {
                        "clearBasicFilter": {
                          "sheetId": sheetId
                        }
                      }
                    ]
                  }
  Sheets.Spreadsheets.batchUpdate(resource, spreadsheetId);
}