use of com.google.api.services.sheets.v4.model.AppendDimensionRequest in project OpenRefine by OpenRefine.
the class SpreadsheetSerializerTests method test30columns.
@Test
public void test30columns() {
// options is null, but unused
SUT.startFile(options);
List<CellData> cells = new ArrayList<>();
for (int i = 0; i < 30; i++) {
String colnum = Integer.toString(i);
CellData cell = new CellData("col" + colnum, "text" + colnum, "text" + colnum, null);
cells.add(cell);
}
SUT.addRow(cells, true);
SUT.addRow(cells, false);
List<Request> requests = SUT.prepareBatch(SUT.getRows());
assertEquals(requests.size(), 2);
for (Request request : requests) {
if (request.getAppendDimension() instanceof AppendDimensionRequest) {
return;
}
}
fail("Failed to find AppendDimensionRequest for columns > 26");
}
use of com.google.api.services.sheets.v4.model.AppendDimensionRequest 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;
}
Aggregations