How to detect a change in a Google Sheets - c#

I'm currently using the Google Spreadsheets API to read a spreadsheet. It works fine, I read and write through it and the changes are immediately reflected in the Google spreadsheet. However I want changes I make through the web browser to be reflected in my app as well.
I can't see any events in the API, can't find any way to do it in Google either.
The spreadsheet is relatively large (1500+ rows), so I can't constantly check every single cell for a change.

Maybe this is helpful. Drive api provides a watch function. I have not yet tested it.
Link: drive api watch

Related

How to persist data in Excel (VSTO) shared among few users?

I have to load huge amount of data, pre-process it, share it among few users and finally gather updates back from users.
This is what I did in my previous project -
Created an excel add-in using C++. Loaded the data in memory using the add-in code and processed it. For each type of data I have sent the processed data to a sheet and saved a new excel file. That way, if I have three types of data, I have created three new excel workbooks. My users then opened those new workbooks, made their changes and dropped a text file that contains their changes (through a button). The main excel keeps polling for those updates (text files) and loads them as soon as they are found. That's the way I get the updates back from my users.
I am not a fan of what I did in my previous project, it produces too many temporary files (of course I can delete those). In my current project I want to use C# VSTO Workbook so I can have more control over excel. I was hoping once I load the data, I will ask my users to open the same excel in Read-Only mode and they will make changes. While testing this, I realized user's excel (opened in read-only) mode does not see the loaded data. And their changes do not update the data held in memory. This probably means I have no idea what I am doing.
Do you guys have any idea how to achieve this? I will really appreciate any help/hint.
Excel supports so-called "co-authoring" mode, when many people can edit the same document at the same time. But there is might be a catch: afaik, you need a Share Point/Office Online server/OneDrive Business to support this scenario (you need a non-free office document server product).
Using VSTO, you can do just the same you have done with C++ add-in, but in C# (means, the set of capabilities is 1:1 - it basically just wraps C++ COM Excel API for .NET)
But for online version of Excel, there may be yet another alternative - javascript addins (now that's called "Office Addins", afaik). But I doubt you'd want to process your "huge amounts of data" with javascript.
So I would say, there is a good rule: Don't fix something that isn't broken :)
If the problem is the number of temporary files, these files is not the only option to transfer data between applications. You know, you can connect two applications directly (so that they can exchange data with messages/updates). Use network, Luke :)
Of course if your 3 users live on 3 deserted islands, totally disconnected from anything, exchanging with text files on USB stick may still be the only viable option...
I think the "web" solution could be: store your file in some "co-authoring"-capable service (sharepoint, google shees, onedrive, officeonline, whatever). Make some web job to update that file in that storage automatically. Just like a "fourth" user would do.

Google Drive API - Can I integrate Google Docs in my web application?

One of the requirements for the web application I'm creating is that users should be able to create and edit documents. I've been searching around and I came across the Google Drive REST API, however I'm a little unsure about what it can do.
From what I understand, the API allows my application to access a user's Google Drive account and their files, being able to open and edit them, as well as create documents using my application.
However, I was hoping that I could be able to use the Google Docs editor itself to create and open/edit documents, but from what I can gather is that the editor is up to me to create, and that I can use the Realtime API to enable the collaboration feature that Google Docs offers.
Is this the case? Is Google leaving the job of actually creating the document editor itself up to me (sorry if I sound like a whiny child here, it's an honest question), or does Drive API also provide their editor? The reason I want to use their editors is because it perfectly fits the requirements for the application, and it will be near impossible for me to compete with their document editor.
If I do I have to create the editor myself, can anyone recommend any open source/free document editors with similar features to that of the Google Docs editor that works with C# ASP.NET, or a way that I could somehow use the Google Docs editor in my application?
The short answer is no, Google does not allow directly editing Google Docs themselves, nor is there an API for recreating the Docs editor.
Bear in mind also that realtime data is not actually stored in Google Drive. Google uses Drive as its organisation method for realtime data, but the data itself, being collaborative, is not just a simple file. What is stored in Drive is a shortcut which links to your app's realtime data. In the case of an existing file (text etc), a shortcut is attached to the file, but it can also be a pure shortcut file, with no non-realtime data at all. Only your app can read or modify that realtime data, in much the same way that only Docs can (directly) work with its realtime data.
You can definitely re-create the capabilities of Google Docs using the realtime API, by exporting from Docs, using the realtime API to collaborate on the exported data, then re-import into Docs if necessary. At that point, Google Docs themselves may be superfluous.
What's involved will be something like this:
Set up an app in the Google developers console
Write the editor, and incorporate it in your app
Get the user to authorize your app to access their Drive
Using the picker, or another method, get the user to select a file.
Import that file from Docs
Collaboratively edit it within your app
Export it back to Docs.
You can embed Google Editor in to your web app and use it to edit, comment or read files, that are stored on Google Drive. You need:
click share button in the file
chose emails you want to share document with (or you can choose any one who has link, or even make it public)
choose permissions you want to grant: read, comment, edit
copy that link and paste it in the <iframe src=google_link width=x height=y></iframe> tag in your UI.

Overwriting existing Google spreadsheet via API (C#)

I would like to overwrite an existing and shared Google spreadsheet X with an other existing Google spreadsheet Y via Drive API v3 or Scripts API from C#. Both are on my own GDrive. Since X is already shared with others, I would like to overwrite spreadsheet X by keeping its URL (and ID).
What I tried: copying sheet-by-sheet is not enough because there is a GAS script behind the spreadsheet and other metadata which is not merged by sheet-by-sheet copy. I need complete overwrite.
Thanks.
It's not possible to do a "complete overwrite" in the same sense that it could be done in several file systems.
In example, revision history and activity tracking can not be removed.
For further details see
https://developers.google.com/google-apps/spreadsheets/
https://developers.google.com/apps-script/reference/spreadsheet/

Getting Revision History from Google drive API in .Net

I am creating WPF application and I am using Google drive API for uploading and downloading files. As the G-mail provides Revision History for files on drive, I also want to implement it in my project and get the detailed list of revisions for a file. Is there some kind of event for this? Can anyone tell me how this work and how can I implement it in my application? And how to revert to the previous version of the file?...
I found answer for the above and also mentioned it in the comments.
I want to use revision history in the scenario like:
I have uploaded a document on Google drive of around(or more) 500 MB and another user
downloads it on their PC and changes 2-3 lines in that document and then upload it again so
instead of uploading the entire document I want the changed version only to be get merged in the already uploaded document as it will be time consuming if one downloads the same
document of 500 MB and make some little changes and then upload the entire document again.
How to achieve this in .net?
You can try calling the google WebAPI
List of revisions
GET /files/{fileId}/revisions
Retrieving a particular revision
GET /files/{fileId}/revisions/{revisionId}
More details at:
https://developers.google.com/drive/v2/reference/#Revisions

Getting real time values from an excel feed

Hello
My application from the stockbroker has this button called "Start excelfeed" which opens an excel file and then updates the incoming prices in realtime. I want these prices extracted into my application (Java), but after several tries with jxl and poi ive found out it only extracts the values which occurred last time i saved the excel files. Are there any possible ways to extract these prices in real time? I'm not sure which method theyre using to feed the excel file, except their app is written in C#.
You can have a look at the VBA code behind the "Start excelfeed" button by hitting Alt+F11 ... Then you can check how the excel macro taps into the data source und try to adapt that in Java
[EDIT]
#Zico Sorry then I got you wrong. In that case I'd try to automate it via the Java Robot Class like user489041 suggested or you could fire up wireshark and try to snoop around the network traffic
They are using the DDE technique and you should use excel automation to pull data from excel into your app.
In the old days, we used DDE links. Chances are your stockbroker addin uses precisely that.
Chances of using DDE from java are pretty slim (close to zero) because it is windows specific. However, possibly there are other methods involved (like COM components or TCP/IP connection). I'd suggest you get the values from teh stockbroker source like the Excelfeed, instead of going through Excel.
Of course, the problem with that is that you won't get help from the vendor of the Excel addin. If things are like they were 8 years ago, they are making tons on your buying the Excel addin and don't really want to help you program against that :)
Worst case, you could use the Java Robot class to create the Excel spreadsheet, save the Excel spreadsheet as a CSV file, then read the CSV file from your Java program.
You can do this with solutions like Obba. Obba allows to access a Java virtual machine running the "Obba Server" directly from Excel.
For your problem, you have to "create" your application from the spreadsheet (load the jar, create an object representing you app - e.g. launching it in a separate thread). Then you can feed the app from Excel... - In this case, Excel is to some extend the "control program" of your app. However, if you start the Obba Server process manually, the process will keep on running if you close and re-open Excel.

Categories

Resources