@Test(expected = IllegalArgumentException.class) public void resizeSpreadsheetShouldThrowErrorWhenColumnSizeLessThanOne() throws IOException { sheetsHelper.resizeSpreadSheet("spreadsheet_id", 0, 0); assertBatchUpdateCalled(0); }
public void resizeSpreadSheet(String spreadsheetId, int sheetId, int columnSize) throws IllegalArgumentException, IOException { if (sheetId < 0) { throw new IllegalArgumentException("Sheet Id should be greater than or equal to 0"); } if (columnSize < 1) { throw new IllegalArgumentException("Column size should be greater than 0"); } GridProperties gridProperties = new GridProperties().setColumnCount(columnSize); SheetProperties sheetProperties = new SheetProperties() .setSheetId(sheetId) .setGridProperties(gridProperties); UpdateSheetPropertiesRequest updateSheetPropertyRequest = new UpdateSheetPropertiesRequest() .setProperties(sheetProperties) .setFields("gridProperties.columnCount"); List<Request> requests = new ArrayList<>(); requests.add(new Request().setUpdateSheetProperties(updateSheetPropertyRequest)); sheetsService.batchUpdate(spreadsheetId, requests); }
SheetsHelper { public void resizeSpreadSheet(String spreadsheetId, int sheetId, int columnSize) throws IllegalArgumentException, IOException { if (sheetId < 0) { throw new IllegalArgumentException("Sheet Id should be greater than or equal to 0"); } if (columnSize < 1) { throw new IllegalArgumentException("Column size should be greater than 0"); } GridProperties gridProperties = new GridProperties().setColumnCount(columnSize); SheetProperties sheetProperties = new SheetProperties() .setSheetId(sheetId) .setGridProperties(gridProperties); UpdateSheetPropertiesRequest updateSheetPropertyRequest = new UpdateSheetPropertiesRequest() .setProperties(sheetProperties) .setFields("gridProperties.columnCount"); List<Request> requests = new ArrayList<>(); requests.add(new Request().setUpdateSheetProperties(updateSheetPropertyRequest)); sheetsService.batchUpdate(spreadsheetId, requests); } }
SheetsHelper { public void resizeSpreadSheet(String spreadsheetId, int sheetId, int columnSize) throws IllegalArgumentException, IOException { if (sheetId < 0) { throw new IllegalArgumentException("Sheet Id should be greater than or equal to 0"); } if (columnSize < 1) { throw new IllegalArgumentException("Column size should be greater than 0"); } GridProperties gridProperties = new GridProperties().setColumnCount(columnSize); SheetProperties sheetProperties = new SheetProperties() .setSheetId(sheetId) .setGridProperties(gridProperties); UpdateSheetPropertiesRequest updateSheetPropertyRequest = new UpdateSheetPropertiesRequest() .setProperties(sheetProperties) .setFields("gridProperties.columnCount"); List<Request> requests = new ArrayList<>(); requests.add(new Request().setUpdateSheetProperties(updateSheetPropertyRequest)); sheetsService.batchUpdate(spreadsheetId, requests); } SheetsHelper(GoogleAccountCredential credential, HttpTransport transport, JsonFactory jsonFactory);   SheetsHelper(@NonNull SheetsService sheetsService); }
SheetsHelper { public void resizeSpreadSheet(String spreadsheetId, int sheetId, int columnSize) throws IllegalArgumentException, IOException { if (sheetId < 0) { throw new IllegalArgumentException("Sheet Id should be greater than or equal to 0"); } if (columnSize < 1) { throw new IllegalArgumentException("Column size should be greater than 0"); } GridProperties gridProperties = new GridProperties().setColumnCount(columnSize); SheetProperties sheetProperties = new SheetProperties() .setSheetId(sheetId) .setGridProperties(gridProperties); UpdateSheetPropertiesRequest updateSheetPropertyRequest = new UpdateSheetPropertiesRequest() .setProperties(sheetProperties) .setFields("gridProperties.columnCount"); List<Request> requests = new ArrayList<>(); requests.add(new Request().setUpdateSheetProperties(updateSheetPropertyRequest)); sheetsService.batchUpdate(spreadsheetId, requests); } SheetsHelper(GoogleAccountCredential credential, HttpTransport transport, JsonFactory jsonFactory);   SheetsHelper(@NonNull SheetsService sheetsService); void resizeSpreadSheet(String spreadsheetId, int sheetId, int columnSize); void insertRow(String spreadsheetId, String sheetName, ValueRange row); void updateRow(String spreadsheetId, String sheetName, ValueRange row); void addSheet(String spreadsheetId, String sheetName); List<List<Object>> getSheetCells(String spreadsheetId, String sheetName); Spreadsheet getSpreadsheet(String spreadsheetId); }
SheetsHelper { public void resizeSpreadSheet(String spreadsheetId, int sheetId, int columnSize) throws IllegalArgumentException, IOException { if (sheetId < 0) { throw new IllegalArgumentException("Sheet Id should be greater than or equal to 0"); } if (columnSize < 1) { throw new IllegalArgumentException("Column size should be greater than 0"); } GridProperties gridProperties = new GridProperties().setColumnCount(columnSize); SheetProperties sheetProperties = new SheetProperties() .setSheetId(sheetId) .setGridProperties(gridProperties); UpdateSheetPropertiesRequest updateSheetPropertyRequest = new UpdateSheetPropertiesRequest() .setProperties(sheetProperties) .setFields("gridProperties.columnCount"); List<Request> requests = new ArrayList<>(); requests.add(new Request().setUpdateSheetProperties(updateSheetPropertyRequest)); sheetsService.batchUpdate(spreadsheetId, requests); } SheetsHelper(GoogleAccountCredential credential, HttpTransport transport, JsonFactory jsonFactory);   SheetsHelper(@NonNull SheetsService sheetsService); void resizeSpreadSheet(String spreadsheetId, int sheetId, int columnSize); void insertRow(String spreadsheetId, String sheetName, ValueRange row); void updateRow(String spreadsheetId, String sheetName, ValueRange row); void addSheet(String spreadsheetId, String sheetName); List<List<Object>> getSheetCells(String spreadsheetId, String sheetName); Spreadsheet getSpreadsheet(String spreadsheetId);  }