1

Currently, in an attempt to just get a basic example working, I have this with which I'm trying to update cells A1:A4 with the value "1".

let mut req = ValueRange::default();
req.values = Some(vec![ vec![ String::from("1"), String::from("1"), String::from("1"), String::from("1") ] ]);
req.range = Some(String::from("A1:A4"));

let result = hub.spreadsheets().values_update(req, SPREADSHEET_ID, "A1:A4")
         .value_input_option("USER_ENTERED")
         .doit();

This responds with a bad request. I've verified that my auth works and that I am able to edit the spreadsheet like so

let mut req = sheets4::ClearValuesRequest::default();
let result = hub.spreadsheets().values_clear(req, SPREADSHEET_ID, "A1:B2").doit();

This clears A1:B2 as expected.

Ideally, I'd like to have a function like this

batch_update(&[1,2,3,4, (etc)], &["A1", "B2", "F3", "G42", (etc)]);

which would set cells A1, B2, F3 .. to 1, 2, 3.. . I am totally unfamiliar with google spreadsheets and spreadsheets in general outside of basic usage.

Mogadishu
  • 213
  • 2
  • 8

1 Answers1

0

I was supposed to read the official google sheets api documentation and not the crate documentation. On the official documentation, I found this https://developers.google.com/sheets/api/samples/writing which helped me get a basic example working like so:

let mut req = sheets4::ValueRange::default();
req.range = Some(String::from("A1:D6"));
req.major_dimension = Some(String::from("ROWS"));
req.values = Some(vec![
    vec!["Item".to_owned(), "Cost".to_owned(), "Stocked".to_owned(), "Ship Date".to_owned()],
    vec!["Wheel".to_owned(), "$20.50".to_owned(), "4".to_owned(), "3/1/2016".to_owned()],
    vec!["Wheel".to_owned(), "$20.50".to_owned(), "4".to_owned(), "3/1/2016".to_owned()],
    vec!["Wheel".to_owned(), "$20.50".to_owned(), "4".to_owned(), "3/1/2016".to_owned()],
    vec!["Wheel".to_owned(), "$20.50".to_owned(), "4".to_owned(), "3/1/2016".to_owned()],
    vec!["Wheel".to_owned(), "$20.50".to_owned(), "=SUM(C2:C5)".to_owned(), "3/1/2016".to_owned()],
]);

let result = hub.spreadsheets().values_update(req, SPREADSHEET_ID, "A1:D6")
    .value_input_option("USER_ENTERED")
    .doit();
Mogadishu
  • 213
  • 2
  • 8