chriszarate / sheetrock

Quickly connect to, query, and lazy-load data from Google Spreadsheets.
https://chriszarate.github.io/sheetrock/
819 stars 122 forks source link

Cells and data formats #46

Closed kvizzt closed 9 years ago

kvizzt commented 10 years ago

Hi Thanks a bunch for a easy to use script and a quick setup. I have a question if anyone have managed to retrieve a cells data-format type.

For instance in the "G" column in Spreadsheet I use percentage format but it displays as decimal formated numbers when I use sheetrock in HTML.

Is there a way to keep the google cell formats or a simple way to convert them back to percentage?

I have created a example here where I can't get the column "G" to swow the numbers in %: http://jsfiddle.net/xhmavwxf/14/

The public spreadsheet can be found here: https://docs.google.com/spreadsheets/d/1d0wHdIXXHI_rfXY-Fqi0ehIVDuUVxGHfTO8sIZG4UOk/edit

I'm quite new to code so any help would be appreciated.

— Daniel

chriszarate commented 10 years ago

Hi Daniel,

The spreadsheet isn't public, so I can't access it. (In the new Sheets, click "Share," then click "Advanced," then change the "Private" to "Anyone with the link" or "Public on the Web."

Chris

kvizzt commented 10 years ago

Hi Chris, Thanks for reading this and taking your time, I have change the public settings according to your request. I have completely missed that setting and that actually helped me with another "bug" (couldn't get it to work on my phone) Thanks.

kvizzt commented 10 years ago

Anyone else found a solution or point me to a direction?

chriszarate commented 10 years ago

Sheetrock passes along the number because it expects that you may want to use it math operations. The data from Google (sometimes) provides the formatted value, but currently there isn't an option to use it. I'll work on that. In the meantime, your options are:

  1. Convert the cells to text.
  2. If you're up for it, write your dataHandler function to use the f property of the cell data (instead of v).
kvizzt commented 10 years ago

Thank you so much for the answer and taking your time.

  1. I not totally sure what you mean with "convert the cells to text" — I tried using the formatting: true/false option but no luck. But that might not be what you meant?
  2. Seems a bit advanced for a novice/designer with limited coding/js skills :).

Looks like I've to wait for google or find another simple solution.

chriszarate commented 9 years ago

After extensive testing, it doesn't seem like Google's API just doesn't consistently support formatted text in a way that can be relied upon. I've now noted this in the documentation.