本文整理汇总了Java中com.google.gdata.data.spreadsheet.SpreadsheetFeed.getEntries方法的典型用法代码示例。如果您正苦于以下问题:Java SpreadsheetFeed.getEntries方法的具体用法?Java SpreadsheetFeed.getEntries怎么用?Java SpreadsheetFeed.getEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gdata.data.spreadsheet.SpreadsheetFeed
的用法示例。
在下文中一共展示了SpreadsheetFeed.getEntries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadSheet
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
/**
* Uses the user's credentials to get a list of spreadsheets. Then asks the
* user which spreadsheet to load. If the selected spreadsheet has multiple
* worksheets then the user will also be prompted to select what sheet to use.
*
* @param reader to read input from the keyboard
* @throws ServiceException when the request causes an error in the Google
* Spreadsheets service.
* @throws IOException when an error occurs in communication with the Google
* Spreadsheets service.
*
*/
public void loadSheet(BufferedReader reader) throws IOException,
ServiceException {
// Get the spreadsheet to load
SpreadsheetFeed feed = service.getFeed(factory.getSpreadsheetsFeedUrl(),
SpreadsheetFeed.class);
List spreadsheets = feed.getEntries();
int spreadsheetIndex = getIndexFromUser(reader, spreadsheets,
"spreadsheet");
SpreadsheetEntry spreadsheet = feed.getEntries().get(spreadsheetIndex);
// Get the worksheet to load
if (spreadsheet.getWorksheets().size() == 1) {
cellFeedUrl = spreadsheet.getWorksheets().get(0).getCellFeedUrl();
} else {
List worksheets = spreadsheet.getWorksheets();
int worksheetIndex = getIndexFromUser(reader, worksheets, "worksheet");
WorksheetEntry worksheet = (WorksheetEntry) worksheets
.get(worksheetIndex);
cellFeedUrl = worksheet.getCellFeedUrl();
}
System.out.println("Sheet loaded.");
}
示例2: loadSheet
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
/**
* Uses the user's creadentials to get a list of spreadsheets. Then asks the
* user which spreadsheet to load. If the selected spreadsheet has multiple
* worksheets then the user will also be prompted to select what sheet to use.
*
* @param reader to read input from the keyboard
* @throws ServiceException when the request causes an error in the Google
* Spreadsheets service.
* @throws IOException when an error occurs in communication with the Google
* Spreadsheets service.
*
*/
public void loadSheet(BufferedReader reader) throws IOException,
ServiceException {
// Get the spreadsheet to load
SpreadsheetFeed feed = service.getFeed(factory.getSpreadsheetsFeedUrl(),
SpreadsheetFeed.class);
List spreadsheets = feed.getEntries();
int spreadsheetIndex = getIndexFromUser(reader, spreadsheets,
"spreadsheet");
SpreadsheetEntry spreadsheet = (SpreadsheetEntry) spreadsheets
.get(spreadsheetIndex);
// Get the worksheet to load
if (spreadsheet.getWorksheets().size() == 1) {
listFeedUrl = spreadsheet.getWorksheets().get(0).getListFeedUrl();
} else {
List worksheets = spreadsheet.getWorksheets();
int worksheetIndex = getIndexFromUser(reader, worksheets, "worksheet");
WorksheetEntry worksheet = (WorksheetEntry) worksheets
.get(worksheetIndex);
listFeedUrl = worksheet.getListFeedUrl();
}
System.out.println("Sheet loaded.");
}
示例3: loadSheet
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
/**
* Uses the user's credentials to get a list of spreadsheets. Then asks the
* user which spreadsheet to load. If the selected spreadsheet has multiple
* worksheets then the user will also be prompted to select what sheet to use.
*
* @param reader to read input from the keyboard
* @throws ServiceException when the request causes an error in the Google
* Spreadsheets service.
* @throws IOException when an error occurs in communication with the Google
* Spreadsheets service.
*
*/
public void loadSheet(BufferedReader reader) throws IOException,
ServiceException {
// Get the spreadsheet to load
SpreadsheetFeed feed = service.getFeed(factory.getSpreadsheetsFeedUrl(),
SpreadsheetFeed.class);
List spreadsheets = feed.getEntries();
int spreadsheetIndex = getIndexFromUser(reader, spreadsheets,
"spreadsheet");
SpreadsheetEntry spreadsheet = (SpreadsheetEntry) spreadsheets
.get(spreadsheetIndex);
URL spreadsheetUrl =
new java.net.URL(spreadsheet.getSpreadsheetLink().getHref());
this.baseUrl = spreadsheetUrl.getProtocol() + "://"
+ spreadsheetUrl.getHost();
this.spreadsheetKey = spreadsheet.getKey();
tablesFeedUrl = new java.net.URL(this.baseUrl + "/feeds/"
+ spreadsheet.getKey() + "/tables");
out.println("Sheet loaded.");
}
示例4: loadSheet
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
/**
* Uses the user's credentials to get a list of spreadsheets. Then asks the
* user which spreadsheet to load. If the selected spreadsheet has multiple
* worksheets then the user will also be prompted to select what sheet to use.
*
* @param reader to read input from the keyboard
* @throws ServiceException when the request causes an error in the Google
* Spreadsheets service.
* @throws IOException when an error occurs in communication with the Google
* Spreadsheets service.
*
*/
public void loadSheet(BufferedReader reader) throws IOException,
ServiceException {
// Get the spreadsheet to load
SpreadsheetFeed feed = service.getFeed(factory.getSpreadsheetsFeedUrl(),
SpreadsheetFeed.class);
List spreadsheets = feed.getEntries();
int spreadsheetIndex = getIndexFromUser(reader, spreadsheets,
"spreadsheet");
SpreadsheetEntry spreadsheet = (SpreadsheetEntry) spreadsheets
.get(spreadsheetIndex);
URL spreadsheetUrl = new java.net.URL(
spreadsheet.getSpreadsheetLink().getHref());
String baseUrl = new java.net.URL(spreadsheetUrl.getProtocol() + "://"
+ spreadsheetUrl.getHost()).toString();
tablesFeedUrl = new java.net.URL(baseUrl + "/feeds/" + spreadsheet.getKey()
+ "/tables");
System.out.println("Sheet loaded.");
}
示例5: getSpreadsheet
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
/**
* Gets the SpreadsheetEntry for the first spreadsheet with that name
* retrieved in the feed.
*
* @param spreadsheet the name of the spreadsheet
* @return the first SpreadsheetEntry in the returned feed, so latest
* spreadsheet with the specified name
* @throws Exception if error is encountered, such as no spreadsheets with the
* name
*/
public SpreadsheetEntry getSpreadsheet(String spreadsheet)
throws Exception {
SpreadsheetQuery spreadsheetQuery
= new SpreadsheetQuery(factory.getSpreadsheetsFeedUrl());
spreadsheetQuery.setTitleQuery(spreadsheet);
SpreadsheetFeed spreadsheetFeed = service.query(spreadsheetQuery,
SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = spreadsheetFeed.getEntries();
if (spreadsheets.isEmpty()) {
throw new Exception("No spreadsheets with that name");
}
return spreadsheets.get(0);
}
示例6: getSsListHelper
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
/**
* Retrieves a <code>List</code> of <code>SpreadsheetEntry</code> instances
* available from the list of Spreadsheets accessible from the authenticated
* account.
*
* @throws EPAuthenticationException
*/
private List<SpreadsheetEntry> getSsListHelper()
throws EPAuthenticationException {
List<SpreadsheetEntry> returnList = null;
try {
SpreadsheetService ssService = getSsService();
SpreadsheetFeed ssFeed = ssService.getFeed(
new URL(SPREADSHEETS_META_FEED),
SpreadsheetFeed.class);
returnList = ssFeed.getEntries();
} catch (com.google.gdata.util.AuthenticationException authEx) {
throw new EPAuthenticationException(
"SS list read access not available");
} catch (com.google.gdata.util.ServiceException svcex) {
System.err.println("ServiceException while retrieving " +
"available spreadsheets: " + svcex.getMessage());
returnList = null;
} catch (java.io.IOException ioex) {
System.err.println("IOException while retrieving " +
"available spreadsheets: " + ioex.getMessage());
returnList = null;
}
return returnList;
}
示例7: GooglesheetClient
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
public GooglesheetClient( Credential credential, String spreadsheetName) throws MalformedURLException, IOException, ServiceException {
SPREADSHEET_FEED_URL = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full");
this.spreadsheetQuery = spreadsheetName;
service.setProtocolVersion(SpreadsheetService.Versions.V3);
service.setOAuth2Credentials( credential );
service.setConnectTimeout( 1000 * QuizParserConstant.CONNECTION_TIMEOUT_SECS );
service.setReadTimeout(1000 * QuizParserConstant.CONNECTION_TIMEOUT_SECS);
// Get Spreadsheet Entry
// Make a request to the API and get all spreadsheets.
SpreadsheetFeed feed = service.getFeed(SPREADSHEET_FEED_URL, SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = feed.getEntries();
// Iterate through all of the spreadsheets returned
for (SpreadsheetEntry spreadsheet : spreadsheets) {
if(spreadsheetQuery.equals(spreadsheet.getTitle().getPlainText())) {
spreadsheetEntry = spreadsheet;
}
}
}
示例8: getSpreadsheet
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
/**
* Retrieve the spreadsheet specified by mSpreadsheetName.
* @param service SpreadsheetService obtained with token to manipulate Google spreadsheets (created in doInBackground)
* @return the spreadsheet specified by the user in Settings.
* @throws IOException
* @throws ServiceException
*/
private SpreadsheetEntry getSpreadsheet( SpreadsheetService service )
throws IOException, ServiceException {
// Generate a URL that returns meta data for spreadsheets
URL metafeedUrl = new URL( GOOGLE_SPREADSHEETS_FEED_URL );
// Fetch spreadsheet feed
SpreadsheetFeed spreadsheetFeed = service.getFeed(metafeedUrl, SpreadsheetFeed.class);
// Find desired spreadsheet (identified by mSpreadSheetName) from list of spreadsheets
List<SpreadsheetEntry> spreadsheets = spreadsheetFeed.getEntries();
SpreadsheetEntry spreadsheet = null;
for ( SpreadsheetEntry entry : spreadsheets ) {
if ( entry.getTitle().getPlainText().equals(mSpreadSheetName) ) {
spreadsheet = entry;
break;
}
}
return spreadsheet;
}
示例9: getSpreadsheet
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
private SpreadsheetEntry getSpreadsheet(String reportSpreadsheetName) throws Throwable
{
SpreadsheetFeed feed = spreadsheetService.getFeed(spreadsheetsFeedUrl, SpreadsheetFeed.class);
for (SpreadsheetEntry spreadsheet : feed.getEntries()) {
if (spreadsheet.getTitle().getPlainText().equalsIgnoreCase(reportSpreadsheetName))
return spreadsheet;
}
throw new RuntimeException(String.format("Either user '%s' has no access to the specified spreadsheet, or there is no spreadsheet named '%s'", Properties.serviceAccountEmail.get(), reportSpreadsheetName));
}
示例10: main
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
// authorization
Credential credential = authorize();
// connect to google service with credential
GoogleService googleService = new SpreadsheetService(APPLICATION_NAME);
googleService.setOAuth2Credentials(credential);
// Define the URL to request. This should never change.
URL SPREADSHEET_FEED_URL = new URL(SPREADSHEETS_FEED);
// Make a request to the API and get all spreadsheets.
SpreadsheetFeed feed = googleService.getFeed(SPREADSHEET_FEED_URL, SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = feed.getEntries();
// Iterate through all of the spreadsheets returned
for (SpreadsheetEntry spreadsheet : spreadsheets) {
// Print the title of this spreadsheet to the screen
System.out.println(spreadsheet.getTitle().getPlainText());
}
// success!
return;
}
catch (IOException e) {
System.err.println(e.getMessage());
}
catch (Throwable t) {
t.printStackTrace();
}
System.exit(1);
}
示例11: getSpreadsheetEntryByTitle
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
public SpreadsheetEntry getSpreadsheetEntryByTitle(String sheetTitle) {
SpreadsheetQuery squery = new SpreadsheetQuery(factory.getSpreadsheetsFeedUrl());
squery.setTitleExact(true);
squery.setTitleQuery(sheetTitle);
SpreadsheetFeed feed = (SpreadsheetFeed) getSpreadsheetFeedQuery(squery, SpreadsheetFeed.class);
List<SpreadsheetEntry> entry = feed.getEntries();
if (entry.size() == 0)
throw new SpreadsheetOperationException("Couldn't find spreadsheet:" + sheetTitle);
return entry.get(0);
}
示例12: extractSpreadSheetEntryFromUrl
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
private SpreadsheetEntry extractSpreadSheetEntryFromUrl() throws SQLException {
try {
URL spreadSheetFeedUrl = this.feedProcessor.getSpreadSheetFeedUrl();
SpreadsheetFeed feed =
this.feedProcessor.getFeed(spreadSheetFeedUrl, SpreadsheetFeed.class);
List<SpreadsheetEntry> entries = feed.getEntries();
return (entries != null && entries.size() > 0) ? entries.get(0) : null;
} catch (Exception e) {
throw new SQLException("Error occurred while extracting spread sheet entry", e);
}
}
示例13: getSpreadSheet
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
private static SpreadsheetEntry getSpreadSheet(String docString, Service service) throws ServiceException, MalformedURLException, IOException {
SpreadsheetFeed feed = service.getFeed(new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full"), SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = feed.getEntries();
for (SpreadsheetEntry spreadsheet : spreadsheets) {
if (spreadsheet.getTitle().getPlainText().equals(docString)) {
return spreadsheet;
}
}
return null;
}
示例14: createRecordInSpreadsheet
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
/**
* Recording a copy of the information somebody used the Streetlight Seattle Reporter app to send to Seattle City Light.
* Google Docs approach inspired by: https://developers.google.com/google-apps/spreadsheets/#adding_a_list_row
* Spreadsheet viewable at: https://docs.google.com/spreadsheet/ccc?key=0AvDYc0olGEwRdE56dTlKMVVZdGYxQkc5eGJEQzJLNkE&usp=drive_web#gid=0
*
* @param parameters names and values from the activity; names are column headers in the spreadsheet.
* @throws AuthenticationException
* @throws MalformedURLException
* @throws IOException
* @throws ServiceException
*/
private void createRecordInSpreadsheet(List<NameValuePair> parameters)
throws AuthenticationException, MalformedURLException, IOException, ServiceException
{
String timeStamp = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(Calendar.getInstance().getTime());
parameters.add(new BasicNameValuePair("Date", timeStamp));
//parameters.remove(object)
SpreadsheetService service = new SpreadsheetService("CodeForSeattle-StreetlightSeattleReporter-v1");
// Authorize the service object for a specific user (see other sections)
final String user = "[email protected]";
final String pword = StringUtil.repeat(getString(R.string.app_initials), 3) + "333";
service.setUserCredentials(user, pword);
// Define the URL to request. This should never change.
URL SPREADSHEET_FEED_URL = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full");
// Make a request to the API and get all spreadsheets.
SpreadsheetFeed feed = service.getFeed(SPREADSHEET_FEED_URL, SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = feed.getEntries();
if (spreadsheets.size() == 0) {
// There were no spreadsheets, act accordingly.
return;
}
SpreadsheetEntry spreadsheet = null;
for (SpreadsheetEntry s : spreadsheets)
{
String title = s.getTitle().getPlainText();
if (title.equals("StreetlightSeattleReporter"))
{
spreadsheet = s;
break;
}
if (spreadsheet == null) // Backup plan.
spreadsheet = spreadsheets.get(0);
}
// Get the first worksheet of the first spreadsheet.
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();
// Set the values of the new row.
for (NameValuePair param : parameters) {
String key = param.getName();
// Refrain from storing these 3 fields in the Google Docs spreadsheet.
if (key.equals("LastName") || key.equals("Phone") || key.equals("Email"))
continue;
row.getCustomElements().setValueLocal(key, param.getValue());
}
// Send the new row to the API for insertion.
row = service.insert(listFeedUrl, row);
}
示例15: loadSheet
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入方法依赖的package包/类
/**
* Uses the user's credentials to get a list of spreadsheets. Then asks the
* user which spreadsheet to load. If the selected spreadsheet has multiple
* worksheets then the user will also be prompted to select what sheet to use.
*
* @param reader to read input from the keyboard
* @throws ServiceException when the request causes an error in the Google
* Spreadsheets service.
* @throws IOException when an error occurs in communication with the Google
* Spreadsheets service.
*
*/
public void loadSheet(BufferedReader reader) throws IOException,
ServiceException {
SpreadsheetFeed feed = service.getFeed(factory.getSpreadsheetsFeedUrl(),
SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = feed.getEntries();
int spreadsheetIndex = getIndexFromUser(reader, spreadsheets, "spreadsheet");
SpreadsheetEntry spreadsheet = feed.getEntries().get(spreadsheetIndex);
worksheetFeedUrl = spreadsheet.getWorksheetFeedUrl();
System.out.println("Spreadsheet loaded.");
}