本文整理汇总了Java中com.google.gdata.data.spreadsheet.SpreadsheetFeed类的典型用法代码示例。如果您正苦于以下问题:Java SpreadsheetFeed类的具体用法?Java SpreadsheetFeed怎么用?Java SpreadsheetFeed使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SpreadsheetFeed类属于com.google.gdata.data.spreadsheet包,在下文中一共展示了SpreadsheetFeed类的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: getSpreadsheetFeedQuery
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入依赖的package包/类
private BaseFeed<?, ?> getSpreadsheetFeedQuery(SpreadsheetQuery squery, Class<? extends BaseFeed<?, ?>> feedClass) {
try {
return service.getFeed(squery, feedClass);
} catch (Exception ex) {
try {
Thread.sleep(RETRY_DELAY);
} catch (InterruptedException e) {
}
// Try to relogin
reauthenticate();
try {
return service.getFeed(squery, SpreadsheetFeed.class);
} catch (Exception ex2) {
throw new SpreadsheetOperationException("Error getting spreadsheet feed. Possibly bad authentication or connection problems. " + ex2);
}
}
}
示例9: 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;
}
示例10: 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));
}
示例11: declareExtensions
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入依赖的package包/类
/**
* Declare the extensions of the feeds for the Google Spreadsheets service.
*/
private void declareExtensions() {
new CellFeed().declareExtensions(extProfile);
new ListFeed().declareExtensions(extProfile);
new RecordFeed().declareExtensions(extProfile);
new SpreadsheetFeed().declareExtensions(extProfile);
new TableFeed().declareExtensions(extProfile);
new WorksheetFeed().declareExtensions(extProfile);
}
示例12: 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);
}
示例13: 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);
}
示例14: 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);
}
}
示例15: extractSpreadSheetFeed
import com.google.gdata.data.spreadsheet.SpreadsheetFeed; //导入依赖的package包/类
private SpreadsheetFeed extractSpreadSheetFeed() throws SQLException {
URL spreadSheetFeedUrl;
try {
spreadSheetFeedUrl = this.feedProcessor.getSpreadSheetFeedUrl();
} catch (MalformedURLException e) {
throw new SQLException("Error occurred while constructing the Spread Sheet Feed URL");
}
SpreadsheetQuery spreadSheetQuery =
TDriverUtil.createSpreadSheetQuery(this.getSpreadSheetName(), spreadSheetFeedUrl);
return this.feedProcessor.getFeed(spreadSheetQuery, SpreadsheetFeed.class);
}