Search in sources :

Example 1 with AppendCellsRequest

use of com.google.api.services.sheets.v4.model.AppendCellsRequest in project OpenRefine by OpenRefine.

the class SpreadsheetSerializer method prepareBatch.

protected List<Request> prepareBatch(List<RowData> rows) {
    List<Request> requests = new ArrayList<>();
    // If this row is wider than our sheet, add columns to the sheet
    int columns = rows.get(0).getValues().size();
    if (columns > maxColumns) {
        AppendDimensionRequest adr = new AppendDimensionRequest();
        adr.setDimension("COLUMNS");
        adr.setLength(columns - maxColumns);
        maxColumns = columns;
        Request req = new Request();
        req.setAppendDimension(adr);
        requests.add(req);
    }
    AppendCellsRequest acr = new AppendCellsRequest();
    acr.setFields("*");
    acr.setSheetId(0);
    acr.setRows(rows);
    Request request = new Request();
    request.setAppendCells(acr);
    requests.add(request);
    return requests;
}
Also used : AppendDimensionRequest(com.google.api.services.sheets.v4.model.AppendDimensionRequest) AppendCellsRequest(com.google.api.services.sheets.v4.model.AppendCellsRequest) BatchUpdateSpreadsheetRequest(com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetRequest) Request(com.google.api.services.sheets.v4.model.Request) AppendDimensionRequest(com.google.api.services.sheets.v4.model.AppendDimensionRequest) AppendCellsRequest(com.google.api.services.sheets.v4.model.AppendCellsRequest) ArrayList(java.util.ArrayList)

Aggregations

AppendCellsRequest (com.google.api.services.sheets.v4.model.AppendCellsRequest)1 AppendDimensionRequest (com.google.api.services.sheets.v4.model.AppendDimensionRequest)1 BatchUpdateSpreadsheetRequest (com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetRequest)1 Request (com.google.api.services.sheets.v4.model.Request)1 ArrayList (java.util.ArrayList)1