如何将数据更新/写入Google电子表格API Android(API V4) [英] How to update/write data to google spreadsheet api android (api v4)

查看:81
本文介绍了如何将数据更新/写入Google电子表格API Android(API V4)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究需要使用Google电子表格api将数据写入和更新到电子表格的应用程序.我已遵循Google Google表格API提供的Android快速入门 Android快速入门,并且能够从Google电子表格中检索数据,但是我不明白如何编写数据.请帮助

I have been working on an application where I need to write and update data to a spreadsheet using google spreadsheet api. I have followed the Android Quickstart provided by google Google Sheets API Android Quickstart and was able to retreive data from the google spreadsheet but I am not able to understand how to write data. Please help

推荐答案

如果您正确地遵循了快速入门教程,那么您将只有几步之遥来学习如何编写数据.

If you followed the Quickstart tutorial correctly, then it you are few steps from learning how to write data.

在快速入门"教程提供的代码中,更改该行

In the code provided in the Quickstart tutorial, change the line

private static final String[] SCOPES = { SheetsScopes.SPREADSHEETS_READONLY };

收件人:

private static final String[] SCOPES = { SheetsScopes.SPREADSHEETS };

这将授予在电子表格上进行写操作的权限.

This will grant access to write on a spreadsheet.

而不是类似的

ValueRange response = this.mService.spreadsheets().values()
                .get(spreadsheetId, range)
                .execute();
List<List<Object>> values = response.getValues();

您必须创建自己的ValueRange实例,在此示例中为valueRange,然后编写:

you must create your own ValueRange instance, valueRange in this example, and then write:

this.mService.spreadsheets().values().update(spreadsheetId, range, valueRange)
                    .setValueInputOption("RAW")
                    .execute();

选择您喜欢的ValueInputOption.

Choose the ValueInputOption of your preference.

这篇关于如何将数据更新/写入Google电子表格API Android(API V4)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆