0

I am trying to get the formatted value of a cell but there seems no such function in Google Apps Script' s Range class. But I found getNumberFormat() function that returns the format of the cell as string. Then I searched for a function that can take a format and a string and return a formatted string. No success. So I decided to roll out one myself. The problem is that the number formats are not documented anywhere. I created a script that would display some number formats. enter image description here

Does anyone know how to read them?

Rubén
  • 34,714
  • 9
  • 70
  • 166
Martin Dimitrov
  • 4,796
  • 5
  • 46
  • 62
  • 2
    There is some documentation included with the spreadsheet [`TEXT()' function documentation](https://support.google.com/docs/answer/3094139). – Mogsdad Nov 03 '14 at 21:54

2 Answers2

1

There's a lib for that! SheetConverter library.

Gist here.

Here's how you could get a single formatted cell:

var formattedValue = SheetConverter.convertCell(value, format);

You'll find other goodies to convert whole ranges into HTML tables, or generate the HTML for a single cell (including fonts, background colors, text colors, and most other formatting elements).

Disclosure: I'm the library author. But that's not my picture on the "ScriptExamples" site!

Mogsdad
  • 44,709
  • 21
  • 151
  • 275