Beispiel #1
0
    Worksheet(WorksheetEntry backingEntry, SpreadsheetService spreadsheetService)
        throws IOException, ServiceException {

      this.backingEntry = backingEntry;
      this.spreadsheetService = spreadsheetService;
      this.rows = backingEntry.getRowCount();
      this.columns = backingEntry.getColCount();
      refreshCachedData();
    }
Beispiel #2
0
    /** Presents the given cell feed as a map from row, column pair to CellEntry. */
    private void refreshCachedData() throws IOException, ServiceException {

      CellQuery cellQuery = new CellQuery(backingEntry.getCellFeedUrl());
      cellQuery.setReturnEmpty(true);
      this.cellFeed = spreadsheetService.getFeed(cellQuery, CellFeed.class);

      //            A subtlety: Spreadsheets row,col numbers are 1-based whereas the
      //            cellEntries array is 0-based. Rather than wasting an extra row and
      //            column worth of cells in memory, we adjust accesses by subtracting
      //            1 from each row or column number.
      cellEntries = new CellEntry[rows][columns];
      for (CellEntry cellEntry : cellFeed.getEntries()) {
        Cell cell = cellEntry.getCell();
        cellEntries[cell.getRow() - 1][cell.getCol() - 1] = cellEntry;
      }
    }
Beispiel #3
0
  public ImportClient(String username, String password, int itemsPerBatch, String spreadsheetName)
      throws Exception {
    ITEMS_PER_BATCH = itemsPerBatch;

    factory = FeedURLFactory.getDefault();
    service = new SpreadsheetService("Props-2-Xls");
    service.setUserCredentials(username, password);
    service.setProtocolVersion(
        SpreadsheetService.Versions
            .V1); // bug workaround! http://code.google.com/p/gdata-java-client/issues/detail?id=103

    spreadsheet = getSpreadsheet(spreadsheetName);
    backingEntry = spreadsheet.getDefaultWorksheet();

    CellQuery cellQuery = new CellQuery(backingEntry.getCellFeedUrl());
    cellQuery.setReturnEmpty(true);
    CellFeed cellFeed = service.getFeed(cellQuery, CellFeed.class);
  }
Beispiel #4
0
 /**
  * Sets this worksheets's row count.
  *
  * @param newRowCount
  * @throws com.google.gdata.util.ServiceException
  */
 void setRowCount(int newRowCount) throws IOException, ServiceException {
   rows = newRowCount;
   backingEntry.setRowCount(newRowCount);
   backingEntry = backingEntry.update();
   refreshCachedData();
 }