Get Google Sheets cell value - javascript

I want to get the value of a cell in google sheets and be able to compare it to something later. When searching for the answer on the web, I was directed to many different places including the Visualization API, and the Sheets Script, but could not find the answer anywhere here. I know I have probably missed something, but I am new to this and would appreciate any pointers you could give.

You may want to use Google Sheets API wherein you can read and write cell values via the spreadsheets.values collection.
Then to be able to properly compare cell values, you need to create and update the conditional formatting within spreadsheets. I suggest that you also check conditional formatting rules.
Lastly, this thread regarding conditional formatting to compare cell contents might also help.

Related

Check list from HTML and parse to Google Sheets

I have an apparel list in Google Sheets with the following columns:
This is only a little part of it. It actually has over 9K items. So here's the thing, I have to manually search each of those legacy numbers on a HTML list provided by the client, which looks like this:
As you can see on the last column, there are some texts like "Completed", "Customer Review", etc. Those values have to be parsed on the google sheet "Status" column. After reviewing some orders and copying those values, the sheet looks like this:
Now, imagine doing this process individually with 9K+ orders, it's a pain in the ass. So I thought there could be a way to automatize this, maybe parsing the values from the HTML through some Javascript to a CSV or anything similar. I've been doing some research but haven't found anything. I'm not asking you to do the job for me. I'm looking for a hint to start this correctly, as it would make a lot easier and faster the work.
Note: this "automatization" isn't a task or job requested to me, I'm a designer (with some programming background) and I have to do the manual process with a deadline, so I thought I could try and speed up this.
Thanks in advance.
I would try using IMPORTHTML so you can add the data from the HTML list on a different tab in Google sheets and then perform an INDEX MATCH or an ArrayFormula to get the data that you need.
There are many ways to compare the data that you need using different formulas, if you can create a demo sheet we could help you finding a formula that could perform the query of the data that you need. As a friendly reminder always try to include a minimal example that reproduces the issue. That way we can provide better insights about what you want to achieve.

How to increase speed of google docs apps scripts

I have a google apps script which fetches data from spreadsheet. The data is fetched pretty slowly, I think because of amount of data. The first call of this function takes till a second:
sheet.getRange(row, coll).getValue()
I think there must be away to create global variables which will be available all the time the spreadsheet is opened. I would store the whole spreadsheet on open and access it, which should be much faster. But I could not find this option.
You can use: sheet.getDataRange().getValues(); it will result in a 2D array containing all values in the sheet up to the last row and column containing data.
For example, if you have a sheet with data in cells A1:B10 and then data in cell E20 the .getDataRange() method will get the range A1:E20 including empty cells.
You can then use loops or filters to access or modify the arrays.
Without more information or knowing what exactly you are trying to achieve that is the best method I can give you.
NOTE: Storing the whole spreadsheet onOpen() is not a very good idea because any changes to the spreadsheet will not be picked up unless you refresh or reopen the spreadsheet.

Query and Update fusion table via HTML form?

I'm pretty new to google maps and fusion tables. I was wondering if it is possible to return queried information from a fusion table and write it into a page using something like innerHTML. Also, I would like to be able to update a fusion table using a standard HTML form. Is this possible and if so can you point me in the right direction? I've been searching around with no results, but it might just be that I don't know how to pose the question. Let me explain as best I can what I'm looking for:
I have a google map with a kml polyline layer. I would like to be able to enter a query into an HTML form (for instance a range of dates, a feature ID, etc.) or click a line feature that has an ID that corresponds to an ID in a fusion table, and run a query that would return the attribute data for the corresponding table entry. Note that the fusion table has no geocoded information, I am just using it as a spreadsheet (I think I understand that fusion tables are easier to query/access than google spreadsheets, but please correct me if I'm wrong).
The form input is pretty self-explanitory - I would just like to be able to enter some info into a form and create a new row in a fusion table.
Thanks in advance for the help/smackdown (whichever it may be)!
Mike
"I want to be able to write the attribute information into the page below my map (using innerHTML)."
This is definitely possible using the "undocumented" Fusion Table JSNOP API. I've used this approach often. I described it in this answer and posted several examples as well: https://stackoverflow.com/a/9778985/1211981
As Odi explained, updates/inserts from the browser are more complicated.
There are several possible solutions to your use case. I suppose you want to a JavaScript-only solution which runs in the browser with no server side code.
To display data from a Fusion Table on Google Maps you should use the FusionTablesLayer, which makes this task really easy and straightforward. There are good examples from Google, e.g. how to change a query using a form or create custom InfoWindows (which would be the preferred way to show data corresponding to what is clicked on the map). If you don't want to care about authentication, just make your tables public, then it should be easy to adapt the examples to your tables.
Another thing is to write data to Fusion Tables: it's not that easy, because here you must care about authentication, see the OAuth guide for detailed information. But at the moment it is not possible to write data directly from the browser to the Fusion Table. But there is hope: With the new Trusted Tester API you can actually do it, but you have to join this group before you can start.
If you can't / don't want to use the new API, consider the server-side approach that I explained here using a script to relay your requests.

Where can I find a screening tool similar to what is used by the Google Stock Screener?

I'm looking to create or find a screener tool similar to this that will read through the records in a database, allow you to select the criteria, create a histogram of said records and criteria, and allow the user to sort and filter through the data, just like the Google Stock Screener.
How would I go about creating something like this or is there somewhere that I could find a plug-in that would allow this? Thanks.
I think Flot would be a good javascript library to try for this. I've used it to display share market data in the past and it deals with time series data fairly well. It's not very hard to add interactive elements.

Writing to an empty cell in Google Spreadsheets

I would like to have some Javascript code running in a web browser write to a Google Spreadsheet in the user's Google account.
The Javascript API is a bit long-winded, involving lots of round trips, but does seem to work. I can successfully log in, create a new spreadsheet, read values from it, update cells, etc. However, I haven't yet figured out how to write to an empty cell. (By empty, I mean that a cell that has had no value written into it yet.)
The issue is: in order to update the value of a cell, I need to know that cell's id. To get the cell's id, I read the cell feed, which shows me the contents (and id) of all non-empty cells. However it won't show me empty cells, therefore I don't know their id, therefore I can't write to them. I've tried making up my own id based on the naming pattern of the other cells, but that doesn't work.
There must be an easy way round this. What is it?
(Context: what I'm actually doing is trying to store user preferences in the user's Google account. The spreadsheet API seems like to be the only one that's feasible to use from a pure Javascript environment. If anyone can suggest any alternatives that's easier to use than Spreadsheets, I'd be grateful.)
I was about to ask a similar question when I stumbled upon yours and while in the process of compiling my question I found the answer!
http://code.google.com/apis/spreadsheets/data/2.0/reference.html#CellParameters
There is a property called return-empty which is set to false by default hence only returning cells that aren't empty in the feed. Set this to "true" in your cell query and you will be able to update the value of empty cells.
I've testing this using the .NET API .

Categories

Resources