Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes Getting values from spreadsheet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Getting values from spreadsheet" Watch "Getting values from spreadsheet" New topic
Author

Getting values from spreadsheet

Padmaksha Mukhopadhyay
Greenhorn

Joined: Nov 27, 2012
Posts: 27
Hi Everyone

My program wants to pull data from 4th coloum in a spreadsheet and count number of occurences in a variable

But the answers are comming wrong and not getting updated

Here is my code .

The 4th coloum has arround 50 values like , p0,p1, p2,p3


And the output comes like

Value of P0: 0
Value of P1: 0
Value of P2: 0
Value of P3: 2

Which is absolutely wrong
What am i doing wrong

Kindly help
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14342
    
  22

What you're doing wrong is that you are using == to compare strings. Use .equals() instead, for example:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14342
    
  22

Wait a minute. Is this Java or JavaScript? Keywords such as "function" and "var" make me think this is JavaScript, which is something completely different than Java.

If it is indeed JavaScript, then my previous answer about using .equals() is not the right answer.
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Yep, it is JavaScript.

What's the expected data from sheet.getDataRange().getValues()?

You are looping the data from position 1 (for var i = 1...) is that correct? Also which kind of Object is data? Is it an Array, an Object, a custom Object? You have to provide us with more information to be able to help.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Getting values from spreadsheet