googleapis / google-api-java-client-services

Generated Java code for Google APIs
Apache License 2.0
623 stars 353 forks source link

Write selectively to a range isn’t working #3125

Closed andresduarte94 closed 1 month ago

andresduarte94 commented 4 years ago

Environment details

  1. OS type and version: N/A
  2. Java version: 1.8
  3. google-api-client version(s): v4-rev20191115-1.30.3

Steps to reproduce

1) Starting from the Sheets Java quickstart [2], use the below code in the main function. 2) Create a Spreadsheet and replace its ID in the code above. 3) Run the code.

Expected behavior: It should update cells A1, B1, C1, E1 and G1. Leaving D1 and F1 as they were.

Actual behavior: It’s updating cells A1, B1, C1, D1 and E1.

Code example


Sheets sheetService = new Sheets.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT)).setApplicationName(APPLICATION_NAME).build();
        String range1 = "Sheet1!A1:G1";
        List<List<Object>> values = Arrays.asList(Arrays.asList("1", "2", "3", null, "5", null, “7”));
        ValueRange vRange = new ValueRange();
        vRange.setRange(range1);
        vRange.setValues(values);
        vRange.setMajorDimension("ROWS");
        try {
            System.out.println(sheetService.spreadsheets().values().update("[SPREADSHEET-ID]", range1, vRange)
                    .setValueInputOption("USER_ENTERED")
                    .setResponseDateTimeRenderOption("FORMATTED_STRING")
                    .execute().toPrettyString());
        } catch (IOException e) {
            e.printStackTrace();
        }

External references such as API reference guides

[1] https://developers.google.com/resources/api-libraries/documentation/sheets/v4/java/latest/ [2] https://developers.google.com/sheets/api/quickstart/java [3] https://developers.google.com/sheets/api/samples/writing#write_selectively_to_a_range [4] https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update?apix_params=%7B%22spreadsheetId%22%3A%221A6RjjlOSQ7zRBYEJUhakv3IyqT-R44XcnFrBW0DFfZk%22%2C%22range%22%3A%22Sheet2!A1%3AG1%22%2C%22responseDateTimeRenderOption%22%3A%22FORMATTED_STRING%22%2C%22valueInputOption%22%3A%22USER_ENTERED%22%2C%22prettyPrint%22%3Atrue%2C%22resource%22%3A%7B%22majorDimension%22%3A%22ROWS%22%2C%22values%22%3A%5B%5B%221%22%2C%222%22%2C%223%22%2Cnull%2C%225%22%2Cnull%2C%227%22%5D%5D%7D%7D

Any additional information below

1) According to Sheets API documentation writing selectively to a range is supported [3]. 2) From “Try this API” it’s working as expected with this request [4].

codyoss commented 4 years ago

All of your links are for Sheets. I think you might want to open an issue under: https://github.com/googleapis/google-api-java-client-services If I missed something please feel free to reopen.

burkedavison commented 1 month ago

Closing this issue as we are unable to provide adequate customer support through this forum. If you feel there is a bug or a feature request associated with this ticket, please open a new issue. Otherwise, https://cloud.google.com/support is best able to provide timely answers to API-specific questions.