本文整理汇总了Java中com.google.gdata.data.spreadsheet.WorksheetFeed.getEntries方法的典型用法代码示例。如果您正苦于以下问题:Java WorksheetFeed.getEntries方法的具体用法?Java WorksheetFeed.getEntries怎么用?Java WorksheetFeed.getEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gdata.data.spreadsheet.WorksheetFeed
的用法示例。
在下文中一共展示了WorksheetFeed.getEntries方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateWorksheet
import com.google.gdata.data.spreadsheet.WorksheetFeed; //导入方法依赖的package包/类
/**
* Updates the worksheet specified by the oldTitle parameter, with the given
* title and sizes. Note that worksheet titles are not unique, so this method
* just updates the first worksheet it finds. Hey, it's just sample code - no
* refunds!
*
* @param oldTitle a String specifying the worksheet to update.
* @param newTitle a String containing the new name for the worksheet.
* @param rowCount the number of rows the new worksheet should have.
* @param colCount the number of columns the new worksheet should have.
*
* @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.
*/
private void updateWorksheet(String oldTitle, String newTitle, int rowCount,
int colCount) throws IOException, ServiceException {
WorksheetFeed worksheetFeed = service.getFeed(worksheetFeedUrl,
WorksheetFeed.class);
for (WorksheetEntry worksheet : worksheetFeed.getEntries()) {
String currTitle = worksheet.getTitle().getPlainText();
if (currTitle.equals(oldTitle)) {
worksheet.setTitle(new PlainTextConstruct(newTitle));
worksheet.setRowCount(rowCount);
worksheet.setColCount(colCount);
worksheet.update();
System.out.println("Worksheet updated.");
return;
}
}
// If it got this far, the worksheet wasn't found.
System.out.println("Worksheet not found: " + oldTitle);
}
示例2: deleteWorksheet
import com.google.gdata.data.spreadsheet.WorksheetFeed; //导入方法依赖的package包/类
/**
* Deletes the worksheet specified by the title parameter. Note that worksheet
* titles are not unique, so this method just updates the first worksheet it
* finds.
*
* @param title a String containing the name of the worksheet to delete.
*
* @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.
*/
private void deleteWorksheet(String title) throws IOException,
ServiceException {
WorksheetFeed worksheetFeed = service.getFeed(worksheetFeedUrl,
WorksheetFeed.class);
for (WorksheetEntry worksheet : worksheetFeed.getEntries()) {
String currTitle = worksheet.getTitle().getPlainText();
if (currTitle.equals(title)) {
worksheet.delete();
System.out.println("Worksheet deleted.");
return;
}
}
// If it got this far, the worksheet wasn't found.
System.out.println("Worksheet not found: " + title);
}
示例3: getWorksheet
import com.google.gdata.data.spreadsheet.WorksheetFeed; //导入方法依赖的package包/类
/**
* Get the WorksheetEntry for the worksheet in the spreadsheet with the
* specified name.
*
* @param spreadsheet the name of the spreadsheet
* @param worksheet the name of the worksheet in the spreadsheet
* @return worksheet with the specified name in the spreadsheet with the
* specified name
* @throws Exception if error is encountered, such as no spreadsheets with the
* name, or no worksheet wiht the name in the spreadsheet
*/
public WorksheetEntry getWorksheet(String spreadsheet, String worksheet)
throws Exception {
SpreadsheetEntry spreadsheetEntry = getSpreadsheet(spreadsheet);
WorksheetQuery worksheetQuery
= new WorksheetQuery(spreadsheetEntry.getWorksheetFeedUrl());
worksheetQuery.setTitleQuery(worksheet);
WorksheetFeed worksheetFeed = service.query(worksheetQuery,
WorksheetFeed.class);
List<WorksheetEntry> worksheets = worksheetFeed.getEntries();
if (worksheets.isEmpty()) {
throw new Exception("No worksheets with that name in spreadhsheet "
+ spreadsheetEntry.getTitle().getPlainText());
}
return worksheets.get(0);
}
示例4: getWsListHelper
import com.google.gdata.data.spreadsheet.WorksheetFeed; //导入方法依赖的package包/类
/**
* Retrieves a <code>List</code> of <code>WorksheetEntry</code> instances
* available from the list of Worksheets in the specified feed
*
* @param wsFeedUrl The feed of worksheets
* @throws EPAuthenticationException
* @return List of worksheets in the specified feed
*/
private List<WorksheetEntry> getWsListHelper(String wsFeedUrl)
throws EPAuthenticationException {
List<WorksheetEntry> returnList = null;
try {
SpreadsheetService ssService = getSsService();
WorksheetFeed wsFeed = ssService.getFeed(
new URL(wsFeedUrl),
WorksheetFeed.class);
returnList = wsFeed.getEntries();
} catch (com.google.gdata.util.AuthenticationException authEx) {
throw new EPAuthenticationException(
"WS list read access not available");
} catch (com.google.gdata.util.ServiceException svcex) {
System.err.println("ServiceException while retrieving " +
"available worksheets: " + svcex.getMessage());
returnList = null;
} catch (java.io.IOException ioex) {
System.err.println("IOException while retrieving " +
"available worksheets: " + ioex.getMessage());
returnList = null;
}
return returnList;
}
示例5: connectWorksheetFeed
import com.google.gdata.data.spreadsheet.WorksheetFeed; //导入方法依赖的package包/类
public static WorksheetEntry connectWorksheetFeed(String user, String password, String documentId, String sheet) throws AuthenticationException
{
WorksheetFeed feed = connectWorksheetFeed(user, password, documentId);
List<WorksheetEntry> worksheets = feed.getEntries();
WorksheetEntry worksheet = null;
if (sheet == null || sheet.isEmpty())
{
worksheet = worksheets.get(0);
} else
{
for (WorksheetEntry we : worksheets)
{
if (we.getTitle().getPlainText().equalsIgnoreCase(sheet))
{
worksheet = we;
}
}
}
return worksheet;
}
示例6: getWorksheetUrl
import com.google.gdata.data.spreadsheet.WorksheetFeed; //导入方法依赖的package包/类
/**
* Gets the worksheet url.
*
* @param spreadsheetService the spreadsheet service
* @param spreadsheetId the spreadsheet id
*/
private URL getWorksheetUrl(SpreadsheetService spreadsheetService, String spreadsheetId)
throws IOException, ServiceException {
if (isCancelled()) {
return null;
}
URL url = new URL(String.format(Locale.US, GET_WORKSHEETS_URI, spreadsheetId));
WorksheetFeed feed = spreadsheetService.getFeed(url, WorksheetFeed.class);
List<WorksheetEntry> worksheets = feed.getEntries();
if (worksheets.size() > 0) {
return worksheets.get(0).getListFeedUrl();
}
return null;
}
示例7: listAllWorksheets
import com.google.gdata.data.spreadsheet.WorksheetFeed; //导入方法依赖的package包/类
/**
* Lists all the worksheets in the loaded spreadsheet.
*
* @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.
*/
private void listAllWorksheets() throws IOException, ServiceException {
WorksheetFeed worksheetFeed = service.getFeed(worksheetFeedUrl,
WorksheetFeed.class);
for (WorksheetEntry worksheet : worksheetFeed.getEntries()) {
String title = worksheet.getTitle().getPlainText();
int rowCount = worksheet.getRowCount();
int colCount = worksheet.getColCount();
System.out.println("\t" + title + " - rows:" + rowCount + " cols: "
+ colCount);
}
}
示例8: getCells
import com.google.gdata.data.spreadsheet.WorksheetFeed; //导入方法依赖的package包/类
/**
* Retrieve the cells of the worksheet designated by the current month from the spreadsheet
* specified in the parameter spreadsheet argument.
* For the specifics of my example, the empty cells of the sheet are retrieved as well.
* @param spreadsheet the spreadsheet to read the cells from (obtained by running getSpreadsheet)
* @param service SpreadsheetService obtained with token to manipulate Google spreadsheets (created in doInBackground)
* @return the cells from the spreadsheet
* @throws IOException
* @throws URISyntaxException
* @throws ServiceException
*/
private List<CellEntry> getCells( SpreadsheetEntry spreadsheet, SpreadsheetService service )
throws IOException, URISyntaxException, ServiceException {
// Get all the worksheets from the spreadsheet
WorksheetFeed worksheetFeed = service.getFeed(spreadsheet.getWorksheetFeedUrl(), WorksheetFeed.class);
List<WorksheetEntry> worksheets = worksheetFeed.getEntries();
// Fetch the desired worksheet (here corresponds to the current month)
WorksheetEntry worksheet = null;
Calendar cal = Calendar.getInstance();
String monthShort = new SimpleDateFormat("MMM").format(cal.getTime()).toLowerCase();
for (WorksheetEntry entry : worksheets) {
String worksheetTitle = entry.getTitle().getPlainText().toLowerCase();
if ( worksheetTitle.startsWith(monthShort) ) {
worksheet = entry;
break;
}
}
// Fetch the cell feed of the worksheet.
if ( worksheet == null )
return null;
else {
// For particular reasons linked to this example we also fetch the empty cells of the sheet
// remove + "?return-empty=true" if you do not need those.
URL cellFeedUrl = new URI(worksheet.getCellFeedUrl().toString() + "?return-empty=true").toURL();
CellFeed cellFeed = service.getFeed(cellFeedUrl, CellFeed.class);
return cellFeed.getEntries();
}
}
示例9: getCurrentWorkSheetEntry
import com.google.gdata.data.spreadsheet.WorksheetFeed; //导入方法依赖的package包/类
public static WorksheetEntry getCurrentWorkSheetEntry(TGSpreadConnection connection,
String sheetName) throws SQLException {
SpreadsheetEntry spreadsheetEntry = connection.getSpreadSheetFeed().getEntries().get(0);
WorksheetQuery worksheetQuery =
TDriverUtil.createWorkSheetQuery(spreadsheetEntry.getWorksheetFeedUrl());
WorksheetFeed worksheetFeed = connection.getFeedProcessor().getFeed(worksheetQuery,
WorksheetFeed.class);
for (WorksheetEntry entry : worksheetFeed.getEntries()) {
if (sheetName.equals(entry.getTitle().getPlainText())) {
return entry;
}
}
return null;
}
示例10: createRecordInSpreadsheet
import com.google.gdata.data.spreadsheet.WorksheetFeed; //导入方法依赖的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);
}
示例11: getWorksheets
import com.google.gdata.data.spreadsheet.WorksheetFeed; //导入方法依赖的package包/类
/**
* Gets all worksheet entries that are part of this spreadsheet.
*
* You must be online for this to work.
*
* @return the list of worksheet entries
*/
public List<WorksheetEntry> getWorksheets()
throws IOException, ServiceException {
WorksheetFeed feed = state.service.getFeed(getWorksheetFeedUrl(),
WorksheetFeed.class);
return feed.getEntries();
}