public WorksheetEntry insertWorksheet(final WorksheetEntry worksheetEntry) throws IOException, ServiceException { WorksheetEntry we = this.spreadsheetService.insert(this.spreadsheetEntry.getWorksheetFeedUrl(), worksheetEntry); this.spreadsheetEntry = this.spreadsheetEntry.getSelf(); return we; }
/** * Constructs a new uninitialized entry, to be populated by the * GData parsers. */ public SpreadsheetEntry() { getCategories().add(CATEGORY); }
/** * Gets the URL for this spreadsheet's worksheets feed. * * You can then create a query using this URL to query this worksheet's * sheets. * * * @return a URL to get a feed of worksheets */ public URL getWorksheetFeedUrl() { try { return new URL(getWorksheetFeedUrlString()); } catch(MalformedURLException e) { throw new RuntimeException("Error in GData server", e); } }
/** * Gets the URL for this spreadseet's worksheets feed as a string. * * <p>This checks for version compatibility also. * * and call that from here, just like in WorksheetEntry. * * @return a string representing the URL for the worksheets feed */ private String getWorksheetFeedUrlString() { Version spreadsheetVersion = state.service.getProtocolVersion(); if (spreadsheetVersion.isCompatible(SpreadsheetService.Versions.V1)) { Link feedLink = this.getLink(Namespaces.WORKSHEETS_LINK_REL, Link.Type.ATOM); return feedLink.getHref(); } else { // must be SpreadsheetService.Versions.V2; only 2 versions for now return ((OutOfLineContent)(this.getContent())).getUri(); } }
/** * 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(); }
private WorksheetEntry getWorkSheet(String sheetName) throws IOException, ServiceException { for (WorksheetEntry workSheet : spreadSheet.getWorksheets()) { if (workSheet.getTitle().getPlainText().equalsIgnoreCase(sheetName)) { return workSheet; } } return null; }
private SpreadsheetEntry connect() { service = new SpreadsheetService("Omlete"); try { service.setOAuth2Credentials(authorize()); URL spreadSheetFeedUrl = new URL( "https://spreadsheets.google.com/feeds/spreadsheets/private/full"); SpreadsheetFeed feed = service.getFeed(spreadSheetFeedUrl, SpreadsheetFeed.class); List<com.google.gdata.data.spreadsheet.SpreadsheetEntry> spreadsheets = feed .getEntries(); for (SpreadsheetEntry sheet : spreadsheets) { LOGGER.debug("Sheet title plain text: " + sheet.getTitle().getPlainText()); if (sheet.getTitle().getPlainText().equalsIgnoreCase(sheetName)) { return sheet; } } } catch (AuthenticationException e) { LOGGER.error(e); } catch (MalformedURLException e) { LOGGER.error(e); } catch (IOException e) { LOGGER.error(e); } catch (ServiceException e) { LOGGER.error(e); } return null; }
/** * Gets the URL for this spreadseet's worksheets feed as a string. * * <p>This checks for version compatibility also. * * and call that from here, just like in WorksheetEntry. * * @return a string representing the URL for the worksheets feed */ private String getWorksheetFeedUrlString() { Version spreadsheetVersion = state.service.getProtocolVersion(); if (spreadsheetVersion.isCompatible(SpreadsheetService.Versions.V1)) { Link feedLink = this.getLink(Namespaces.WORKSHEETS_LINK_REL, Link.Type.ATOM); return feedLink.getHref(); } else { // must be SpreadsheetService.Versions.V2; only 2 versions for now return ((OutOfLineContent)(this.getContent())).getUri(); } }
/** * 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(); }
private void loadWorksheets() throws Exception { LOGGER.debug("Loading worksheets..."); final List<WorksheetEntry> worksheetEntries = this.spreadsheetEntry.getWorksheets(); for (final WorksheetEntry worksheetEntry : worksheetEntries) { final GSWorksheet worksheet = new GSWorksheet(this, worksheetEntry, true); LOGGER.debug("Loaded worksheet with name '" + worksheet.getName() + "'"); this.addWorksheet(worksheet); } }
/** * Constructs a new uninitialized entry, to be populated by the * GData parsers. */ public SpreadsheetEntry() { getCategories().add(CATEGORY); }
/** * Gets the URL for this spreadsheet's worksheets feed. * * You can then create a query using this URL to query this worksheet's * sheets. * * * @return a URL to get a feed of worksheets */ public URL getWorksheetFeedUrl() { try { return new URL(getWorksheetFeedUrlString()); } catch(MalformedURLException e) { throw new RuntimeException("Error in GData server", e); } }
/** * Constructs a new entry by doing a shallow copy from another BaseEntry * instance. */ public SpreadsheetEntry(BaseEntry sourceEntry) { super(sourceEntry); getCategories().add(CATEGORY); }
/** * Gets the first worksheet in the spreadsheet. * * This is very useful if your spreadsheet only has one worksheet. * * @return the first worksheet */ public WorksheetEntry getDefaultWorksheet() throws IOException, ServiceException { String url = getWorksheetFeedUrlString() + "/default"; return state.service.getEntry(new URL(url), WorksheetEntry.class); }
/** * Constructs a new entry by doing a shallow copy from another BaseEntry * instance. */ public SpreadsheetEntry(BaseEntry sourceEntry) { super(sourceEntry); getCategories().add(CATEGORY); }
/** * Gets the first worksheet in the spreadsheet. * * This is very useful if your spreadsheet only has one worksheet. * * @return the first worksheet */ public WorksheetEntry getDefaultWorksheet() throws IOException, ServiceException { String url = getWorksheetFeedUrlString() + "/default"; return state.service.getEntry(new URL(url), WorksheetEntry.class); }