I use the following code to add a list row, it successful. But it looks like complex.
SpreadsheetService service =
new SpreadsheetService("MySpreadsheetIntegration-v1");
// Define the URL to request. This should never change.
URL SPREADSHEET_FEED_URL = new URL(
"https://spreadsheets.google.com/feeds/spreadsheets/private/full");
// TODO Make a request to the API and get all spreadsheets.
/*
In Here, Instead of request all spread sheets,
I want to request only my spread sheet which I have stored on Google Drive.
*/
SpreadsheetFeed feed = service.getFeed(SPREADSHEET_FEED_URL,
SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = feed.getEntries();
if (spreadsheets.size() == 0) {
// TODO: There were no spreadsheets, act accordingly.
}
SpreadsheetEntry spreadsheet = spreadsheets.get(0);
System.out.println(spreadsheet.getTitle().getPlainText());
// Get the first worksheet of the first spreadsheet.
// TODO: Choose a worksheet more intelligently based on your
// app's needs.
WorksheetFeed worksheetFeed = service.getFeed(
spreadsheet.getWorksheetFeedUrl(), WorksheetFeed.class);
List<WorksheetEntry> worksheets = worksheetFeed.getEntries();
WorksheetEntry worksheet = worksheets.get(0);
// Fetch the list feed of the worksheet.
URL listFeedUrl = worksheet.getListFeedUrl();
ListFeed listFeed = service.getFeed(listFeedUrl, ListFeed.class);
// Create a local representation of the new row.
ListEntry row = new ListEntry();
row.getCustomElements().setValueLocal("firstname", "Joe");
row.getCustomElements().setValueLocal("lastname", "Smith");
// Send the new row to the API for insertion.
row = service.insert(listFeedUrl, row);
And now, I want to be simple.
Instead of request all spread sheets, I want to request only my spread sheet which I have stored on Google Drive.
I have the link of file spread sheet, docs.google.com/spreadsheet/ccc?key=KEYOFFILE#gid=0.
Please tell me how, Thanks,