0

I have a Google Form that stores it's result in google sheets of which the following screen grab I have shown.

screen grab

Google form is also calculating score and that is why there is this column named Score in spreadsheet.

Selected cell at bottom shows 20/30 as value. But on the top field(i.e., highlighted) it just says 20. I want to read the whole value 20/30 through Google App Scripts. As of now I am only getting 20 through Google App Scripts.

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • 1
    Please don't use the excel tag where it's not relevant – Tim Williams Jan 10 '18 at 00:11
  • @TimWilliams - actually, this does appear to be cross-platform but you're probably right; the [tag:excel] doesn't belong largely due to the title. –  Jan 10 '18 at 00:22

2 Answers2

1

This is raw value of 20 in a cell with a custom number format of something like 0\/\3\0. The author assumes you know the numerator is going to be 30 so that can be hard-coded into any calculation or formula. You can only read the raw value of the displayed numerator (e.g. 20) unless you grab the cell's number format and parse out the denominator.

tldr:

You type in 20 and the cell shows 20/30 but its value remains 20.

1

Short Answer

Use getDisplayValue() instead of getValue().

Explanation

As was already explained, what are you seeing is a "number format". It was applied by the integration between Google Forms and Google Sheets.

In order to "get what you see" through Google Apps Script, use getDisplayValue() instead of getValue().

Related Q/A

Difference between getValue() and getDisplayValue() on google app script

Community
  • 1
  • 1
Rubén
  • 34,714
  • 9
  • 70
  • 166