class SpreadsheetApp method .setNumberFormat()

SpreadsheetApp is the Apps Script service.

.setNumberFormat() is the method name you will see after a dot in your code.

What it does

Sets how numbers and dates display in a range.

Why it's used

  • Force currency or percent display on calculated columns.
  • Make exported reports look right without manual formatting.

Common errors

  • Forgetting parentheses on setNumberFormat. Write SpreadsheetApp.setNumberFormat(), not SpreadsheetApp.setNumberFormat or setNumberFormat by itself.
  • Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').setNumberFormat().
  • Adding spaces where they do not belong. Write SpreadsheetApp.setNumberFormat(), not SpreadsheetApp .setNumberFormat(), SpreadsheetApp.setNumberFormat (), or SpreadsheetApp . setNumberFormat().
  • Wrong capitalization. Use SpreadsheetApp and setNumberFormat, not spreadsheetapp or setnumberformat.

Explore

Related methods

  • .clearFormat()

    Removes only formatting from a range, keeping values.

  • .setWrap()

    Turns text wrapping on or off for cells in a range.

  • .clear()

    Removes values, formatting, and notes from a range.

  • .setFontColor()

    Sets the text color of cells in a range.

  • .getNumRows()

    Returns how many rows are in a range.

Better Sheets tutorials

How To Change Date Format Automatically

How To Change Date Format Automatically

Create automations to change date format based on the format you want, i...
How to Format Timestamp to Day and Month

How to Format Timestamp to Day and Month

Create a formatted timestamp to the full name of the day and month. Form...
How to Trigger Macros Daily

How to Trigger Macros Daily

Automate your apps script and macros you can record.
Introducing SheetFools

Introducing SheetFools

Free google sheets automations pranks you can use right now. Launching p...
Visicalc 2023 Design Walkthrough

Visicalc 2023 Design Walkthrough

Design walkthrough of VisiCalc 2023. Watch this if you'd like to see the...
Visicalc 2023 Quick Walkthrough

Visicalc 2023 Quick Walkthrough

This is a fun template I created for April 1st. Take a quick walk throug...

Related blog posts

Written guides about SpreadsheetApp.setNumberFormat().

Browse the blog