ryan-d-williams / MMM-GoogleSheets

Google Sheets Module for MagicMirror
MIT License
30 stars 2 forks source link

Auto range? #25

Closed retroflex closed 3 months ago

retroflex commented 2 years ago

Nice module! Is there any way to automatically set the range (e.g. A1:B6) to include all non-empty cells in the sheet? In case I want to show a sheet that varies in nr of rows for example.

ryan-d-williams commented 2 years ago

@retroflex

You can't currently do this with the module directly, but you can accomplish this by creating a new sheet that does the filtering for you, and then you can import that sheet into the module.

What is the use case if you don't mind me asking? If it something that a lot of people will use I can add it in a future version.

retroflex commented 2 years ago

My use case is I use a sheet for my kids' weekly recurring activities for the family to keep up with everyday life. My partner wants to add different stuff to this, like comments (more rows) or more activites (more columns) easily. Not a big deal, just would be a nice feature.

brandonfake69 commented 1 year ago

Would love this!

There is getDataRange() in Apps Script that could accomplish this. Let the user pass in 'auto' (or something like that) for the range and then in code.gs if range is 'auto' then call getDataRange() instead of getRange(). This would be a simple way to not break existing users that are calling a fixed range.

https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet#getdatarange

ryan-d-williams commented 3 months ago

@retroflex @brandonfake69

This feature has been added! Check out the updated README for more details.

Note that in order to use it, you will need to update to the latest version of the library (currently 20). Check out the README for details on how to do that. You will also need to redeploy your apps script (this is mentioned in the instructions on updating the library).

Thanks for the great suggestion! Please send me screenshots of you using the module so I can add them as inspiration for others in the README!