在Google Spreadsheets中写入空单元格 [英] Writing to an empty cell in Google Spreadsheets

查看:86
本文介绍了在Google Spreadsheets中写入空单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在浏览器中运行一些Javascript代码,并将其写入用户Google帐户中的Google Spreadsheet。


$ b Javascript API有点长,啰嗦,涉及很多往返,但似乎工作。我可以成功登录,创建新的电子表格,从中读取值,更新单元格等。但是,我还没有想出如何写入空的单元格。 (空,我的意思是一个没有写入值的单元格)。

问题是:为了更新单元格的值,我需要知道该单元的ID。为了获得单元格的ID,我读取了单元格feed,它显示了所有非空单元格的内容(和id)。然而,它不会让我看到空单元格,因此我不知道它们的ID,因此我不能写信给他们。我试图根据其他单元格的命名模式来编写我自己的id,但这不起作用。



必须有一个简单的方法。这是什么?



(上下文:我实际做的是试图将用户偏好存储在用户的Google帐户中。电子表格API似乎是唯一的这是可行的使用从一个纯粹的Javascript环境。如果任何人都可以建议任何比电子表格更容易使用的替代品,我会很感激。)

解决方案

当我偶然发现你的问题时,我正要问一个类似的问题,而在编译我的问题的过程中,我找到了答案!



http://code.google.com/apis/spreadsheets/data/2.0/ reference.html#CellParameters



有一个名为 return-empty 的属性,默认情况下它设置为false,因此只返回单元格在Feed中不是空的。在你的单元格查询中设置为true,你就可以更新空单元格的值。



我已经使用.NET API测试了它。 / p>

I would like to have some Javascript code running in a web browser write to a Google Spreadsheet in the user's Google account.

The Javascript API is a bit long-winded, involving lots of round trips, but does seem to work. I can successfully log in, create a new spreadsheet, read values from it, update cells, etc. However, I haven't yet figured out how to write to an empty cell. (By empty, I mean that a cell that has had no value written into it yet.)

The issue is: in order to update the value of a cell, I need to know that cell's id. To get the cell's id, I read the cell feed, which shows me the contents (and id) of all non-empty cells. However it won't show me empty cells, therefore I don't know their id, therefore I can't write to them. I've tried making up my own id based on the naming pattern of the other cells, but that doesn't work.

There must be an easy way round this. What is it?

(Context: what I'm actually doing is trying to store user preferences in the user's Google account. The spreadsheet API seems like to be the only one that's feasible to use from a pure Javascript environment. If anyone can suggest any alternatives that's easier to use than Spreadsheets, I'd be grateful.)

解决方案

I was about to ask a similar question when I stumbled upon yours and while in the process of compiling my question I found the answer!

http://code.google.com/apis/spreadsheets/data/2.0/reference.html#CellParameters

There is a property called return-empty which is set to false by default hence only returning cells that aren't empty in the feed. Set this to "true" in your cell query and you will be able to update the value of empty cells.

I've testing this using the .NET API .

这篇关于在Google Spreadsheets中写入空单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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