Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Spreadsheet Java API: URL from CellEntry?

I am using Java to read from a Google Spreadsheet. The user may select certain cells, and later may update those cells, but in between may shut the program down.

So I would like to store a unique URL for a spreadsheet cell to disk, for later use in updating that spreadsheet cell, when the program restarts. Is there any way to get a unique URL from a CellEntry?

The only way I know of doing this is by getting the cell's row & columns:

int row = cell.getCell().getRow();
int col = cell.getCell().getCol();

And then using that in a query for cells with min/max rows/cols:

URL cellFeedUrl = new URI(worksheetFeed.getCellFeedUrl().toString()
+ "?min-row="
+ Integer.toString(row)
+ "&max-row="
+ Integer.toString(row)
    + "&max-col="
    + Integer.toString(col))
+ "&min-col="
+ Integer.toString(col)).toURL();
CellFeed cellFeed = spreadsheetService.getFeed(cellFeedUrl, CellFeed.class);

But this seems a little crazy, since by the time I have a cell entry, I shouldn't have to search for it again. Wishful thinking?

like image 648
Nels Beckman Avatar asked Mar 24 '26 00:03

Nels Beckman


1 Answers

Fast batch update solution: What is the fastest way to update a google spreadsheet with a lot of data through the spreadsheet api?

Also look at CellDemo.java http://gdata-java-client.googlecode.com/svn-history/r51/trunk/java/sample/spreadsheet/cell/CellDemo.java

it shows you can do an update this way:

CellEntry newEntry = new CellEntry(row, col, formulaOrValue);
service.insert(cellFeedUrl, newEntry);
like image 124
eddyparkinson Avatar answered Mar 26 '26 15:03

eddyparkinson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!