urbancups / node-sheets

read rows from google spreadsheet with google's sheets api
MIT License
20 stars 4 forks source link

Option to not provide default values for empty cells #11

Open sondrele opened 5 years ago

sondrele commented 5 years ago

Hi and thanks for this small library! :) I'm using it to fetch a few sheets that has rows, many of which has optional columns in them.

This works ok by default, but when I apply formatting (e.g. number formatting) to the cells, the effectiveValue function will provide default values instead of leaving them as empty. This makes it a little harder to distinguish between a valid 0 value, and an empty value that has just been mapped to 0. (It's possible to derive whether a cell has a defined value in a cell based on whether its stringValue is defined or not, but (to me) this does not seam like the intended purpose of this field.) The same applies for currency and dates.

Would you be opposed to changing this behavior, or provide an option to only format values that actually are defined, and not set default values? Or would I be better off rolling my own implementation of this?

benedictjohannes commented 4 years ago

@sondrele I'm using your library gatsby-source-google-spreadsheets for, you know, building Gatsby sites. For text and number content, it works like a charm. I would like to extend the functionality to include inline images (use the getLink() spreadsheet cell function to get link to image) to feed to Gatsby's image handling system. Forking your library won't be enough, as image type is not handled by this.

I noticed that yours weren't replied to after more than one year. Your suggestion should be rather straightforward to implement. I think you might be able to enhance your plugin better if your package the sheets fetching directly.

sondrele commented 4 years ago

@benedictjohannes Yeah I think you're right :) I haven't worked with Gatsby for a while, so that plugin has remained mostly untouched, but I opened an issue in the repo and might have some free time to look into it later this summer, or happy to accept a PR if you're into providing one :)