1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Using Google Spreadsheets - Zend Framework Manual</title>
</head>
<body>
<table width="100%">
<tr valign="top">
<td width="85%">
<table width="100%">
<tr>
<td width="25%" style="text-align: left;">
<a href="zend.gdata.docs.html">Using Google Documents List Data API</a>
</td>
<td width="50%" style="text-align: center;">
<div class="up"><span class="up"><a href="zend.gdata.html">Zend_Gdata</a></span><br />
<span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
</td>
<td width="25%" style="text-align: right;">
<div class="next" style="text-align: right; float: right;"><a href="zend.gdata.gapps.html">Using Google Apps Provisioning</a></div>
</td>
</tr>
</table>
<hr />
<div id="zend.gdata.spreadsheets" class="section"><div class="info"><h1 class="title">Using Google Spreadsheets</h1></div>
<p class="para">
The Google Spreadsheets data <acronym class="acronym">API</acronym> allows client applications to view
and update Spreadsheets content in the form of Google data <acronym class="acronym">API</acronym> feeds.
Your client application can request a list of a user's spreadsheets,
edit or delete content in an existing Spreadsheets worksheet, and
query the content in an existing Spreadsheets worksheet.
</p>
<p class="para">
See <a href="http://code.google.com/apis/spreadsheets/overview.html" class="link external">» http://code.google.com/apis/spreadsheets/overview.html</a>
for more information about the Google Spreadsheets <acronym class="acronym">API</acronym>.
</p>
<div class="section" id="zend.gdata.spreadsheets.creating" name="zend.gdata.spreadsheets.creating"><div class="info"><h1 class="title">Create a Spreadsheet</h1></div>
<p class="para">
The Spreadsheets data <acronym class="acronym">API</acronym> does not currently provide a way to
programmatically create or delete a spreadsheet.
</p>
</div>
<div class="section" id="zend.gdata.spreadsheets.listspreadsheets" name="zend.gdata.spreadsheets.listspreadsheets"><div class="info"><h1 class="title">Get a List of Spreadsheets</h1></div>
<p class="para">
You can get a list of spreadsheets for a particular user by using
the <span class="methodname">getSpreadsheetFeed()</span> method of the Spreadsheets
service. The service will return a
<span class="classname">Zend_Gdata_Spreadsheets_SpreadsheetFeed</span> object
containing a list of spreadsheets associated with the authenticated
user.
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$service</span> = Zend_Gdata_Spreadsheets::<span style="color: #006600;">AUTH_SERVICE_NAME</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$client</span> = Zend_Gdata_ClientLogin::<span style="color: #006600;">getHttpClient</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$user</span>, <span style="color: #0000ff;">$pass</span>, <span style="color: #0000ff;">$service</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$spreadsheetService</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Gdata_Spreadsheets<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$client</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$feed</span> = <span style="color: #0000ff;">$spreadsheetService</span>-><span style="color: #006600;">getSpreadsheetFeed</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
</div>
<div class="section" id="zend.gdata.spreadsheets.listworksheets" name="zend.gdata.spreadsheets.listworksheets"><div class="info"><h1 class="title">Get a List of Worksheets</h1></div>
<p class="para">
A given spreadsheet may contain multiple worksheets. For each
spreadsheet, there's a worksheets metafeed listing all the
worksheets in that spreadsheet.
</p>
<p class="para">
Given the spreadsheet key from the <id> of a
<span class="classname">Zend_Gdata_Spreadsheets_SpreadsheetEntry</span>
object you've already retrieved, you can fetch a feed
containing a list of worksheets associated with that spreadsheet.
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Gdata_Spreadsheets_DocumentQuery<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setSpreadsheetKey</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$spreadsheetKey</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$feed</span> = <span style="color: #0000ff;">$spreadsheetService</span>-><span style="color: #006600;">getWorksheetFeed</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$query</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
The resulting <span class="classname">Zend_Gdata_Spreadsheets_WorksheetFeed</span>
object feed represents the response from the server. Among other
things, this feed contains a list of
<span class="classname">Zend_Gdata_Spreadsheets_WorksheetEntry </span>
objects (<strong class="command">$feed->entries</strong>), each of which represents a
single worksheet.
</p>
</div>
<div class="section" id="zend.gdata.spreadsheets.listfeeds" name="zend.gdata.spreadsheets.listfeeds"><div class="info"><h1 class="title">Interacting With List-based Feeds</h1></div>
<p class="para">
A given worksheet generally contains multiple rows, each
containing multiple cells. You can request data from the
worksheet either as a list-based feed, in which each entry
represents a row, or as a cell-based feed, in which each
entry represents a single cell. For information on cell-based feeds, see <a href="zend.gdata.spreadsheets.html#zend.gdata.spreadsheets.cellfeeds" class="link">Interacting with cell-based
feeds</a>.
</p>
<p class="para">
The following sections describe how to get a list-based feed,
add a row to a worksheet, and send queries with various query
parameters.
</p>
<p class="para">
The list feed makes some assumptions about how the data is laid
out in the spreadsheet.
</p>
<p class="para">
In particular, the list feed treats the first row of the
worksheet as a header row; Spreadsheets dynamically creates
<acronym class="acronym">XML</acronym> elements named after the contents of header-row cells.
Users who want to provide Gdata feeds should not put any data
other than column headers in the first row of a worksheet.
</p>
<p class="para">
The list feed contains all rows after the first row up to the
first blank row. The first blank row terminates the data set.
If expected data isn't appearing in a feed, check the worksheet
manually to see whether there's an unexpected blank row in the
middle of the data. In particular, if the second row of the
spreadsheet is blank, then the list feed will contain no data.
</p>
<p class="para">
A row in a list feed is as many columns wide as the worksheet itself.
</p>
<div class="section" id="zend.gdata.spreadsheets.listfeeds.get" name="zend.gdata.spreadsheets.listfeeds.get"><div class="info"><h1 class="title">Get a List-based Feed</h1></div>
<p class="para">
To retrieve a worksheet's list feed, use the
<span class="methodname">getListFeed()</span> method of the Spreadsheets service.
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Gdata_Spreadsheets_ListQuery<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setSpreadsheetKey</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$spreadsheetKey</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setWorksheetId</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$worksheetId</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$listFeed</span> = <span style="color: #0000ff;">$spreadsheetService</span>-><span style="color: #006600;">getListFeed</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$query</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
The resulting <span class="classname">Zend_Gdata_Spreadsheets_ListFeed</span>
object <var class="varname">$listfeed</var> represents a response from the
server. Among other things, this feed contains an array of
<span class="classname">Zend_Gdata_Spreadsheets_ListEntry</span> objects
(<strong class="command">$listFeed->entries</strong>), each of which represents
a single row in a worksheet.
</p>
<p class="para">
Each <span class="classname">Zend_Gdata_Spreadsheets_ListEntry</span> contains an
array, <span class="property">custom</span>, which contains the data for that
row. You can extract and display this array:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$rowData</span> = <span style="color: #0000ff;">$listFeed</span>-><span style="color: #006600;">entries</span><span style="color: #66cc66;">[</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">]</span>-><span style="color: #006600;">getCustom</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$rowData</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$customEntry</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$customEntry</span>-><span style="color: #006600;">getColumnName</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> . <span style="color: #ff0000;">" = "</span> . <span style="color: #0000ff;">$customEntry</span>-><span style="color: #006600;">getText</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">}</span></div></li></ol></div></div></div>
<p class="para">
An alternate version of this array, <span class="property">customByName</span>,
allows direct access to an entry's cells by name. This is
convenient when trying to access a specific header:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$customEntry</span> = <span style="color: #0000ff;">$listFeed</span>-><span style="color: #006600;">entries</span><span style="color: #66cc66;">[</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">]</span>-><span style="color: #006600;">getCustomByName</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'my_heading'</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$customEntry</span>-><span style="color: #006600;">getColumnName</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> . <span style="color: #ff0000;">" = "</span> . <span style="color: #0000ff;">$customEntry</span>-><span style="color: #006600;">getText</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
</div>
<div class="section" id="zend.gdata.spreadsheets.listfeeds.reverse" name="zend.gdata.spreadsheets.listfeeds.reverse"><div class="info"><h1 class="title">Reverse-sort Rows</h1></div>
<p class="para">
By default, rows in the feed appear in the same order as the
corresponding rows in the GUI; that is, they're in order by
row number. To get rows in reverse order, set the reverse
properties of the <span class="classname">Zend_Gdata_Spreadsheets_ListQuery</span>
object to <b><tt>TRUE</tt></b>:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Gdata_Spreadsheets_ListQuery<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setSpreadsheetKey</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$spreadsheetKey</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setWorksheetId</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$worksheetId</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setReverse</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'true'</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$listFeed</span> = <span style="color: #0000ff;">$spreadsheetService</span>-><span style="color: #006600;">getListFeed</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$query</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
Note that if you want to order (or reverse sort) by a
particular column, rather than by position in the worksheet,
you can set the <span class="property">orderby</span> value of the
<span class="classname">Zend_Gdata_Spreadsheets_ListQuery</span> object to
<em class="emphasis">column:<the header of that column></em>.
</p>
</div>
<div class="section" id="zend.gdata.spreadsheets.listfeeds.sq" name="zend.gdata.spreadsheets.listfeeds.sq"><div class="info"><h1 class="title">Send a Structured Query</h1></div>
<p class="para">
You can set a <span class="classname">Zend_Gdata_Spreadsheets_ListQuery</span>'s
<span class="property">sq</span> value to produce a feed with entries that meet
the specified criteria. For example, suppose you have a worksheet
containing personnel data, in which each row represents
information about a single person. You wish to retrieve all rows
in which the person's name is "John" and the person's age is over
25. To do so, you would set <span class="property">sq</span> as follows:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Gdata_Spreadsheets_ListQuery<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setSpreadsheetKey</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$spreadsheetKey</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setWorksheetId</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$worksheetId</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setSpreadsheetQuery</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'name=John and age>25'</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$listFeed</span> = <span style="color: #0000ff;">$spreadsheetService</span>-><span style="color: #006600;">getListFeed</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$query</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
</div>
<div class="section" id="zend.gdata.spreadsheets.listfeeds.addrow" name="zend.gdata.spreadsheets.listfeeds.addrow"><div class="info"><h1 class="title">Add a Row</h1></div>
<p class="para">
Rows can be added to a spreadsheet by using the
<span class="methodname">insertRow()</span> method of the Spreadsheet service.
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$insertedListEntry</span> = <span style="color: #0000ff;">$spreadsheetService</span>-><span style="color: #006600;">insertRow</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$rowData</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000ff;">$spreadsheetKey</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000ff;">$worksheetId</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
The <var class="varname">$rowData</var> parameter contains an array of column
keys to data values. The method returns a
<span class="classname">Zend_Gdata_Spreadsheets_SpreadsheetsEntry</span> object
which represents the inserted row.
</p>
<p class="para">
Spreadsheets inserts the new row immediately after the last row
that appears in the list-based feed, which is to say
immediately before the first entirely blank row.
</p>
</div>
<div class="section" id="zend.gdata.spreadsheets.listfeeds.editrow" name="zend.gdata.spreadsheets.listfeeds.editrow"><div class="info"><h1 class="title">Edit a Row</h1></div>
<p class="para">
Once a <span class="classname">Zend_Gdata_Spreadsheets_ListEntry</span> object
is fetched, its rows can be updated by using the
<span class="methodname">updateRow()</span> method of the Spreadsheet service.
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$updatedListEntry</span> = <span style="color: #0000ff;">$spreadsheetService</span>-><span style="color: #006600;">updateRow</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$oldListEntry</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000ff;">$newRowData</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
The <var class="varname">$oldListEntry</var> parameter contains the list entry
to be updated. <var class="varname">$newRowData</var> contains an array of
column keys to data values, to be used as the new row data.
The method returns a
<span class="classname">Zend_Gdata_Spreadsheets_SpreadsheetsEntry</span> object
which represents the updated row.
</p>
</div>
<div class="section" id="zend.gdata.spreadsheets.listfeeds.deleterow" name="zend.gdata.spreadsheets.listfeeds.deleterow"><div class="info"><h1 class="title">Delete a Row</h1></div>
<p class="para">
To delete a row, simply invoke <span class="methodname">deleteRow()</span> on the
<span class="classname">Zend_Gdata_Spreadsheets</span> object with the existing
entry to be deleted:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$spreadsheetService</span>-><span style="color: #006600;">deleteRow</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$listEntry</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
Alternatively, you can call the <span class="methodname">delete()</span> method of
the entry itself:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$listEntry</span>-><span style="color: #006600;">delete</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
</div>
</div>
<div class="section" id="zend.gdata.spreadsheets.cellfeeds" name="zend.gdata.spreadsheets.cellfeeds"><div class="info"><h1 class="title">Interacting With Cell-based Feeds</h1></div>
<p class="para">
In a cell-based feed, each entry represents a single cell.
</p>
<p class="para">
Note that we don't recommend interacting with both a cell-based
feed and a list-based feed for the same worksheet at the same time.
</p>
<div class="section" id="zend.gdata.spreadsheets.cellfeeds.get" name="zend.gdata.spreadsheets.cellfeeds.get"><div class="info"><h1 class="title">Get a Cell-based Feed</h1></div>
<p class="para">
To retrieve a worksheet's cell feed, use the
<span class="methodname">getCellFeed()</span> method of the Spreadsheets service.
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Gdata_Spreadsheets_CellQuery<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setSpreadsheetKey</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$spreadsheetKey</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setWorksheetId</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$worksheetId</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$cellFeed</span> = <span style="color: #0000ff;">$spreadsheetService</span>-><span style="color: #006600;">getCellFeed</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$query</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
The resulting <span class="classname">Zend_Gdata_Spreadsheets_CellFeed</span>
object <var class="varname">$cellFeed</var> represents a response from the
server. Among other things, this feed contains an array of
<span class="classname">Zend_Gdata_Spreadsheets_CellEntry</span> objects
(<strong class="command">$cellFeed>entries</strong>), each of which represents
a single cell in a worksheet. You can display this information:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$cellFeed</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$cellEntry</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span></div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000ff;">$row</span> = <span style="color: #0000ff;">$cellEntry</span>-><span style="color: #006600;">cell</span>-><span style="color: #006600;">getRow</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000ff;">$col</span> = <span style="color: #0000ff;">$cellEntry</span>-><span style="color: #006600;">cell</span>-><span style="color: #006600;">getColumn</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000ff;">$val</span> = <span style="color: #0000ff;">$cellEntry</span>-><span style="color: #006600;">cell</span>-><span style="color: #006600;">getText</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">"$row, $col = $val<span style="color: #000099; font-weight: bold;">\n</span>"</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">}</span></div></li></ol></div></div></div>
</div>
<div class="section" id="zend.gdata.spreadsheets.cellfeeds.cellrangequery" name="zend.gdata.spreadsheets.cellfeeds.cellrangequery"><div class="info"><h1 class="title">Send a Cell Range Query</h1></div>
<p class="para">
Suppose you wanted to retrieve the cells in the first column
of a worksheet. You can request a cell feed containing only
this column as follows:
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Gdata_Spreadsheets_CellQuery<span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setMinCol</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setMaxCol</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$query</span>-><span style="color: #006600;">setMinRow</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">)</span>;</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$feed</span> = <span style="color: #0000ff;">$spreadsheetService</span>-><span style="color: #006600;">getCellsFeed</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$query</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
This requests all the data in column 1, starting with row 2.
</p>
</div>
<div class="section" id="zend.gdata.spreadsheets.cellfeeds.updatecell" name="zend.gdata.spreadsheets.cellfeeds.updatecell"><div class="info"><h1 class="title">Change Contents of a Cell</h1></div>
<p class="para">
To modify the contents of a cell, call
<span class="methodname">updateCell()</span> with the row, column,
and new value of the cell.
</p>
<div class="programlisting php"><div class="phpcode"><div class="php" style="font-family: monospace;"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$updatedCell</span> = <span style="color: #0000ff;">$spreadsheetService</span>-><span style="color: #006600;">updateCell</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$row</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000ff;">$col</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000ff;">$inputValue</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000ff;">$spreadsheetKey</span>,</div></li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color: #0000ff;">$worksheetId</span><span style="color: #66cc66;">)</span>;</div></li></ol></div></div></div>
<p class="para">
The new data is placed in the specified cell in the worksheet.
If the specified cell contains data already, it will be
overwritten. Note: Use <span class="methodname">updateCell()</span> to change
the data in a cell, even if the cell is empty.
</p>
</div>
</div>
</div>
<hr />
<table width="100%">
<tr>
<td width="25%" style="text-align: left;">
<a href="zend.gdata.docs.html">Using Google Documents List Data API</a>
</td>
<td width="50%" style="text-align: center;">
<div class="up"><span class="up"><a href="zend.gdata.html">Zend_Gdata</a></span><br />
<span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
</td>
<td width="25%" style="text-align: right;">
<div class="next" style="text-align: right; float: right;"><a href="zend.gdata.gapps.html">Using Google Apps Provisioning</a></div>
</td>
</tr>
</table>
</td>
<td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
float: left;
width: 186px;
padding: 5px;
font-size: smaller;
}
ul.toc {
margin: 0px 5px 5px 5px;
padding: 0px;
}
ul.toc li {
font-size: 85%;
margin: 1px 0 1px 1px;
padding: 1px 0 1px 11px;
list-style-type: none;
background-repeat: no-repeat;
background-position: center left;
}
ul.toc li.header {
font-size: 115%;
padding: 5px 0px 5px 11px;
border-bottom: 1px solid #cccccc;
margin-bottom: 5px;
}
ul.toc li.active {
font-weight: bold;
}
ul.toc li a {
text-decoration: none;
}
ul.toc li a:hover {
text-decoration: underline;
}
</style>
<ul class="toc">
<li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
<li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
<li class="header up"><a href="reference.html">Zend Gdata Reference</a></li>
<li class="header up"><a href="zend.gdata.html">Zend_Gdata</a></li>
<li><a href="zend.gdata.analytics.html">Using Google Analytics</a></li>
<li><a href="zend.gdata.authsub.html">Authenticating with AuthSub</a></li>
<li><a href="zend.gdata.books.html">Using the Book Search Data API</a></li>
<li><a href="zend.gdata.clientlogin.html">Authenticating with ClientLogin</a></li>
<li><a href="zend.gdata.calendar.html">Using Google Calendar</a></li>
<li><a href="zend.gdata.docs.html">Using Google Documents List Data API</a></li>
<li class="active"><a href="zend.gdata.spreadsheets.html">Using Google Spreadsheets</a></li>
<li><a href="zend.gdata.gapps.html">Using Google Apps Provisioning</a></li>
<li><a href="zend.gdata.photos.html">Using Picasa Web Albums</a></li>
<li><a href="zend.gdata.youtube.html">Using the YouTube Data API</a></li>
<li><a href="zend.gdata.exception.html">Catching Gdata Exceptions</a></li>
</ul>
</td>
</tr>
</table>
</body>
</html>
|