예제 #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();
    }
예제 #2
0
    List<List<Object>> getRowsOfCells(
        SpreadsheetService service,
        WorksheetEntry worksheet,
        int startRow, // 1-based
        int rowCount)
        throws IOException, ServiceException {
      URL cellFeedUrl = worksheet.getCellFeedUrl();

      int minRow = startRow;
      int maxRow = Math.min(worksheet.getRowCount(), startRow + rowCount - 1);
      int cols = worksheet.getColCount();
      int rows = worksheet.getRowCount();

      CellQuery cellQuery = new CellQuery(cellFeedUrl);
      cellQuery.setMinimumRow(minRow);
      cellQuery.setMaximumRow(maxRow);
      cellQuery.setMaximumCol(cols);
      cellQuery.setMaxResults(rows * cols);
      cellQuery.setReturnEmpty(false);

      CellFeed cellFeed = service.query(cellQuery, CellFeed.class);
      List<CellEntry> cellEntries = cellFeed.getEntries();

      List<List<Object>> rowsOfCells = new ArrayList<List<Object>>(rowCount);
      for (CellEntry cellEntry : cellEntries) {
        Cell cell = cellEntry.getCell();
        if (cell != null) {
          int row = cell.getRow() - startRow;
          int col = cell.getCol() - 1;

          while (row >= rowsOfCells.size()) {
            rowsOfCells.add(new ArrayList<Object>());
          }
          List<Object> rowOfCells = rowsOfCells.get(row);

          while (col >= rowOfCells.size()) {
            rowOfCells.add(null);
          }
          rowOfCells.set(col, cell.getValue());
        }
      }
      return rowsOfCells;
    }
예제 #3
0
    public WorksheetBatchRowReader(
        ImportingJob job,
        String fileSource,
        SpreadsheetService service,
        WorksheetEntry worksheet,
        int batchSize) {
      this.job = job;
      this.fileSource = fileSource;
      this.service = service;
      this.worksheet = worksheet;
      this.batchSize = batchSize;

      this.totalRows = worksheet.getRowCount();
    }
 public void addEmptyRows(WorksheetEntry worksheetEntry, int newRows)
     throws IOException, ServiceException {
   int rows = worksheetEntry.getRowCount();
   worksheetEntry.setRowCount(rows + newRows);
   worksheetEntry.update();
 }