How do I get the Formatted Value of a cell using Google Apps Script

You will have to know the type of data coming from each cell and handle it the right way in each case...

if it's a string, keep it as it is, if it's a date use Utilities.formatDate to show it the way you want (see doc here) and if it's a number you can also format it as necessary using Utilities.formatString (see doc here).

To get the type, use instanceof, for an example have a look at this recent post


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!