1

I am not able to do get current active cell from DOM. More specifically I need the row number from the active cell. I have tried to do this by writing a google app script

function doGet() { 
  const activeRowNumber = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getActiveCell().getRow();
  const result = {
    activeRowNumber: activeRowNumber
  }
  return JSON.stringify(result)
}

which works fine and returns the active cell row number, but the problem is when I deploy it as a web app or API executable to make it possible to run it on any google spreadsheet from my chrome extension. When I make the REST API request, it always returns 1

my question is very related to Get ActiveCell of Google Sheet client side

Is there some way how can I achieve this? Please let me know.

My idea for an ugly workaround is to create a google spreadsheet Add-on, deploy it to the chrome store for add-ons. Make the user of my chrome extension install this spreadsheets add-on so the add-on can communicate somehow with my chrome extension, to push data about current active cell row number to my chrome extension. Would such communication be possible without using some external database or API?

Linux_cat
  • 45
  • 12
  • A Google Sheet can be published as JSON. If you're using the sheet as a data source, publish it and then use a function in the extension to poll the data and check for differences. More on publishing as JSON [in this SO answer](https://stackoverflow.com/questions/30082277/accessing-a-new-style-public-google-sheet-as-json). – Brian Sep 19 '17 at 15:16
  • @BrianBennett I am not using the sheet as a data source. What I need is a universal script that can be run on any sheet and will retrieve the current active cell's row number. I am listening to mouseclick event with a google chrome extension content script, then I need to retrieve the active row number to process data inside that row. – Linux_cat Sep 19 '17 at 23:23

0 Answers0