I have been trying to do this, but seem to be unable to comprehend the whole picture.
I have a spreadsheet augmented with custom scripts that goes around the internet and collects stuff. I have added a new menu - 'download source data', which is intended to allow the user (me in this case) to have 'one click' download of the raw data in csv format. The problem is that the default export in csv is not doing all I need and I prefer to create the content of the file in script. I use ContentService. When I press the menu it goes and creates what is needed, however I would expect the script to trigger a download in the browser, but this does not happen.
So my question is: is it possible to do this from a menu (ActiveSpreadsheet.addMenu and there reference to my function). If yes, how do I tell the browser to start downloading the file with the contents of the created TextOutput. I have tried downloadAsFile('filename') but it does nothing. No errors are displayed.