Ejemplo n.º 1
0
  public void testAddRows() throws SmartsheetException, IOException {
    // create sheet
    sheet = smartsheet.sheetResources().createSheet(createSheetObject());

    // get column
    PaginationParameters parameters =
        new PaginationParameters.PaginationParametersBuilder().setIncludeAll(true).build();
    PagedResult<Column> wrapper =
        smartsheet
            .sheetResources()
            .columnResources()
            .listColumns(sheet.getId(), EnumSet.allOf(ColumnInclusion.class), parameters);

    Column addedColumn1 = wrapper.getData().get(0);
    Column addedColumn2 = wrapper.getData().get(1);

    // Specify cell values for first row.
    List<Cell> cellsA =
        new Cell.AddRowCellsBuilder()
            .addCell(addedColumn1.getId(), true)
            .addCell(addedColumn2.getId(), "New status")
            .build();

    // Specify contents of first row.
    row = new Row.AddRowBuilder().setCells(cellsA).setToBottom(true).build();

    // Specify cell values for second row.
    List<Cell> cellsB =
        new Cell.AddRowCellsBuilder()
            .addCell(addedColumn1.getId(), true)
            .addCell(addedColumn2.getId(), "New status")
            .build();

    // Specify contents of first row.
    Row rowA = new Row.AddRowBuilder().setCells(cellsB).setToBottom(true).build();

    newRows =
        smartsheet.sheetResources().rowResources().addRows(sheet.getId(), Arrays.asList(row, rowA));

    List<Column> columns = wrapper.getData();
    addedColumn = columns.get(1);
  }
Ejemplo n.º 2
0
  @Test
  public void testUpdateRows() throws SmartsheetException, IOException {
    // create sheet
    Sheet sheet = smartsheet.sheetResources().createSheet(createSheetObject());
    PaginationParameters parameters =
        new PaginationParameters.PaginationParametersBuilder().setIncludeAll(true).build();
    PagedResult<Column> wrapper =
        smartsheet
            .sheetResources()
            .columnResources()
            .listColumns(sheet.getId(), EnumSet.allOf(ColumnInclusion.class), parameters);

    Column addedColumn1 = wrapper.getData().get(0);
    Column addedColumn2 = wrapper.getData().get(1);

    // Specify cell values for first row.
    List<Cell> cellsA =
        new Cell.AddRowCellsBuilder()
            .addCell(addedColumn1.getId(), true)
            .addCell(addedColumn2.getId(), "New status")
            .build();

    // Specify contents of first row.
    Row row = new Row.AddRowBuilder().setCells(cellsA).setToBottom(true).build();
    List<Row> newRows =
        smartsheet.sheetResources().rowResources().addRows(sheet.getId(), Arrays.asList(row));

    // Updated cells //correct
    List<Cell> cellsB =
        new Cell.UpdateRowCellsBuilder()
            .addCell(addedColumn1.getId(), true)
            .addCell(addedColumn2.getId(), "Updtaed status")
            .build();

    Row rowB = new Row.UpdateRowBuilder().setCells(cellsB).setRowId(newRows.get(0).getId()).build();

    List<Row> updatedRows =
        smartsheet.sheetResources().rowResources().updateRows(sheet.getId(), Arrays.asList(rowB));

    assertNotNull(updatedRows);
    deleteSheet(sheet.getId());
  }