安卓:添加一行到谷歌小号$ P $垫表 [英] Android : Add row into Google Spread Sheet
本文介绍了安卓:添加一行到谷歌小号$ P $垫表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用下面的code到添加列表行,它的成功。但它看起来像复杂。
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.
而是要求所有特殊$ P $垫张, 我想只要求我的小号$ P $垫,我已经存储在谷歌驱动器表。
Instead of request all spread sheets, I want to request only my spread sheet which I have stored on Google Drive.
我有文件■$ P $衬垫片的链接,docs.google.com/s$p$padsheet/ccc?key=KEYOFFILE#gid=0。
I have the link of file spread sheet, docs.google.com/spreadsheet/ccc?key=KEYOFFILE#gid=0.
请告诉我怎么样, 谢谢你,
Please tell me how, Thanks,
推荐答案
好了, 我要自己解决。
Okay, I fix it myself.
而不是使用
URL SPREADSHEET_FEED_URL = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full");
我们使用:
URL SPREADSHEET_FEED_URL = new URL("https://spreadsheets.google.com/feeds/worksheets/KEYOFTHEFILE/private/full")
谢谢
这篇关于安卓:添加一行到谷歌小号$ P $垫表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文