[英]How to construct a proper values_update call using the google_sheets4 crate?
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".目前,为了让一个基本的例子工作,我有这个,我试图用值“1”更新单元格 A1:A4。
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.这会按预期清除 A1:B2。
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.. .这会将单元格 A1、B2、F3 .. 设置为 1、2、3.. 。 I am totally unfamiliar with google spreadsheets and spreadsheets in general outside of basic usage.
除了基本用法之外,我对谷歌电子表格和电子表格完全不熟悉。
I was supposed to read the official google sheets api documentation and not the crate documentation.我应该阅读官方的 google sheet api 文档,而不是 crate 文档。 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:
在官方文档中,我发现这个https://developers.google.com/sheets/api/samples/writing帮助我得到了一个基本的例子,如下所示:
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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.