This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Zend_Gdata_Spreadsheets.xml
395 lines (331 loc) · 17.5 KB
/
Zend_Gdata_Spreadsheets.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<!-- EN-Revision: 22432 -->
<!-- Reviewed: no -->
<sect1 id="zend.gdata.spreadsheets">
<title>Google Tabellenkalkulation verwenden</title>
<para>
Die Google Tabellenkalkulations Daten <acronym>API</acronym> erlaubt es Client Anwendungen
Inhalte von Tabellenkalkulationen zu sehen und Inhalte von Tabellenkalkulationen in der form
von Google Daten <acronym>API</acronym> Feeds zu aktualisieren. Die eigene Client Anwendung
kann eine Liste von Tabellenkalkulationen eines Benutzer anfragen, Inhalte eines bestehenden
Arbeitsblatts der Tabellenkalkulation bearbeiten oder löschen, und den Inhalt eines
bestehenden Arbeitsblatt der Tabellenkalkulation abfragen.
</para>
<para>
Siehe <ulink
url="http://code.google.com/apis/spreadsheets/overview.html">http://code.google.com/apis/spreadsheets/overview.html</ulink>
für weitere Informationen über die Google's Tabellenkalkulations <acronym>API</acronym>.
</para>
<sect2 id="zend.gdata.spreadsheets.creating">
<title>Eine Tabellenkalkulation erstellen</title>
<para>
Die Tabellenkalkulations Daten <acronym>API</acronym> bietet aktuell noch keinen Weg um
eine Tabellenkalkulation programmtechnisch zu erstellen oder zu löschen.
</para>
</sect2>
<sect2 id="zend.gdata.spreadsheets.listspreadsheets">
<title>Eine Liste von Tabellenkalkulationen erhalten</title>
<para>
Man kann eine Liste von Tabellenkalkulationen für einen bestimmten Benutzer erhalten
indem die <methodname>getSpreadsheetFeed()</methodname> Methode des
Tabellenkalkulationsservices verwendet wird. Der Service wird ein
<classname>Zend_Gdata_Spreadsheets_SpreadsheetFeed</classname> Objekt zurückgeben das
eine Liste von Tabellenkalkulationen enthält die mit dem authentifizierten Benutzer
authentifiziert sind.
</para>
<programlisting language="php"><![CDATA[
$service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$spreadsheetService = new Zend_Gdata_Spreadsheets($client);
$feed = $spreadsheetService->getSpreadsheetFeed();
]]></programlisting>
</sect2>
<sect2 id="zend.gdata.spreadsheets.listworksheets">
<title>Eine Liste von Arbeitsblättern erhalten</title>
<para>
Eine gegebene Tabellenkalkulation kann mehrere Arbeitsblätter enthalten. Für jedes
Arbeitsblass gibt es einen Arbeitsblatt Metafeed der alle Arbeitsblätter in dieser
Tabellenkalkulation auflistet.
</para>
<para>
Mit der Schlüssel der Tabellenkalkulation von der <id> des
<classname>Zend_Gdata_Spreadsheets_SpreadsheetEntry</classname> Objekts das man bereits
empfangen hat, kann mein einen Feed holen der eine Liste von Arbeitsblättern enthält die
mit dieser Tabellenkalkulation assoziiert sind.
</para>
<programlisting language="php"><![CDATA[
$query = new Zend_Gdata_Spreadsheets_DocumentQuery();
$query->setSpreadsheetKey($spreadsheetKey);
$feed = $spreadsheetService->getWorksheetFeed($query);
]]></programlisting>
<para>
Der sich ergebende <classname>Zend_Gdata_Spreadsheets_WorksheetFeed</classname>
Objektfeed repräsentiert die Antwort des Servers. Neben anderen Dingen enthält dieser
Feed eine Liste von <classname>Zend_Gdata_Spreadsheets_WorksheetEntry </classname>
Objekten (<command>$feed->entries</command>), wobei jedes ein einzelnes Arbeitsblatt
repräsentiert.
</para>
</sect2>
<sect2 id="zend.gdata.spreadsheets.listfeeds">
<title>Mit listen-basierenden Feeds interagieren</title>
<para>
Ein gegebenes Arbeitsblatt enthält generell mehrere Zeilen, wobei jede mehrere Zellen
enthält. Man kann Daten vom Arbeitsblatt entweder als listen-basierenden Feed anfragen,
in dem jeder Eintrag eine Zeile repräsentiert, oder als zellen-basierenden Feed, in dem
jeder Eintrag eine einzelne Zelle repräsentiert. Für Informationen über
zellen-basierende Feeds kann auch unter <link
linkend="zend.gdata.spreadsheets.cellfeeds">Interaktion mit zellen-basierenden
Feeds</link> nachgesehen werden.
</para>
<para>
Die folgenden Sektionen beschreiben wie man einen Listen basierender Feed erhält, eine
Zeile zu einem Arbeitsblatt hinzufügt, und Abfragen mit verschiedenen Abfrage Parametern
sendet.
</para>
<para>
Der Listenfeed macht einige Annahmen darüber wie die Daten in der Tabellenkalkulation
ausgelegt sind.
</para>
<para>
Im speziellen, behandelt der Listenfeed die erste Zeile des Arbeitsblattes als
Kopfzeile; Tabellenkalkulationen erstellen dynamisch <acronym>XML</acronym> Elemente
welche nach dem Inhalt der Kopfzeilen-Zellen benannt sind. Benutzer welche Gdata Feeds
anbieten wollen, sollten keine andere Daten als Spaltenheader in der ersten Zeile eines
Arbeitsblattes ablegen.
</para>
<para>
Der Listenfeed enthält alle Zeilen nach der ersten Zeile bis zur ersten leeren Zeile.
Die erste leere Zeile terminiert das Datenset. Wenn angenommene Daten nicht in einem
Feed erscheinen, muß das Arbeitsblatt manuell darauf geprüft werden ob eine unerwartete
leere Zeile in der Mitte der Daten vorhanden ist. Im speziellen wird der Listenfeed,
wenn die zweite Zeile der Tabellenkalkulation leer ist, keine Daten enthalten.
</para>
<para>
Eine Zeile in einem Listenfeed ist soviele Spalten breit wie das Arbeitsblatt selbst.
</para>
<sect3 id="zend.gdata.spreadsheets.listfeeds.get">
<title>Einen listen-basierenden Feed erhalten</title>
<para>
Um einen Listenfeed eines Arbeitsblattes zu erhalten, kann die
<methodname>getListFeed()</methodname> Methode des Tabellenkalkulations Services
verwendet werden.
</para>
<programlisting language="php"><![CDATA[
$query = new Zend_Gdata_Spreadsheets_ListQuery();
$query->setSpreadsheetKey($spreadsheetKey);
$query->setWorksheetId($worksheetId);
$listFeed = $spreadsheetService->getListFeed($query);
]]></programlisting>
<para>
Das sich ergebende <classname>Zend_Gdata_Spreadsheets_ListFeed</classname> Objekt
<varname>$listfeed</varname> repräsentiert eine Antwort vom Server. Neben anderen
Dingen enthält dieser Feed ein Array von
<classname>Zend_Gdata_Spreadsheets_ListEntry</classname> Objekten
(<command>$listFeed->entries</command>), wobei jedes eine einzelne Zeile in einem
Arbeitsblatt repräsentiert.
</para>
<para>
Jeder <classname>Zend_Gdata_Spreadsheets_ListEntry</classname> enthält ein Array,
<property>custom</property>, welches die Daten für die Zeile enthält. Dieses Array
kann extrahiert und angezeigt werden:
</para>
<programlisting language="php"><![CDATA[
$rowData = $listFeed->entries[1]->getCustom();
foreach($rowData as $customEntry) {
echo $customEntry->getColumnName() . " = " . $customEntry->getText();
}
]]></programlisting>
<para>
Eine alternative Version dieses Arrays, <property>customByName</property>, erlaubt
den direkten Zugriff zu dem Eintrag einer Zelle durch den Namen. Das ist üblich,
wenn man versucht auf einen speziellen Header zuzugreifen:
</para>
<programlisting language="php"><![CDATA[
$customEntry = $listFeed->entries[1]->getCustomByName('my_heading');
echo $customEntry->getColumnName() . " = " . $customEntry->getText();
]]></programlisting>
</sect3>
<sect3 id="zend.gdata.spreadsheets.listfeeds.reverse">
<title>Umgekehrt-sortierte Zeilen</title>
<para>
Standardmäßig werden die Zeilen im Feed in der gleichen Reihenfolge angezeigt wie in
den entsprechenden Zeilen im GUI; das ist die Reihenfolge anhand der Zeilennummer.
Um Zeilen in einer umgekehrten Reihenfolge zu erhalten, muß die reverse Eigenschaft
des <classname>Zend_Gdata_Spreadsheets_ListQuery</classname> Objektes auf
<constant>TRUE</constant> gesetzt werden:
</para>
<programlisting language="php"><![CDATA[
$query = new Zend_Gdata_Spreadsheets_ListQuery();
$query->setSpreadsheetKey($spreadsheetKey);
$query->setWorksheetId($worksheetId);
$query->setReverse('true');
$listFeed = $spreadsheetService->getListFeed($query);
]]></programlisting>
<para>
Es ist zu beachten, das wenn nach einer speziellen Spalte sortiert (oder umgekehrt
sortiert) werden soll, statt nach der Position im Arbeitsblatt, kann der
<property>orderby</property> Wert des
<classname>Zend_Gdata_Spreadsheets_ListQuery</classname> Objekts auf
<emphasis>column:<Der Header dieser Spalte></emphasis> gesetzt werden.
</para>
</sect3>
<sect3 id="zend.gdata.spreadsheets.listfeeds.sq">
<title>Eine strukturierte Abfrage senden</title>
<para>
Der <property>sq</property> Wert von
<classname>Zend_Gdata_Spreadsheets_ListQuery</classname> kann gesetzt werden um
einen Feed mit Einträgen zu erzeugen die ein spezielles Kriterium erfüllen.
Angenommen, man hat ein Arbeitsblatt das personelle Daten enthält, in denen jede
Zeile Informationen über eine einzelne Person repräsentiert, und man will alle
Zeilen empfangen will in denen der Name der Person "John" ist, und das Alter der
Person über 25. Um das tu tun, muß <property>sq</property> wie folgt gesetzt werden:
</para>
<programlisting language="php"><![CDATA[
$query = new Zend_Gdata_Spreadsheets_ListQuery();
$query->setSpreadsheetKey($spreadsheetKey);
$query->setWorksheetId($worksheetId);
$query->setSpreadsheetQuery('name=John and age>25');
$listFeed = $spreadsheetService->getListFeed($query);
]]></programlisting>
</sect3>
<sect3 id="zend.gdata.spreadsheets.listfeeds.addrow">
<title>Hinzufügen einer Zeile</title>
<para>
Zeilen können zu einer Tabellenkalkulation hinzugefügt werden durch Verendung der
<methodname>insertRow()</methodname> Methode des Tabellenkalkulations Services.
</para>
<programlisting language="php"><![CDATA[
$insertedListEntry = $spreadsheetService->insertRow($rowData,
$spreadsheetKey,
$worksheetId);
]]></programlisting>
<para>
Der <varname>$rowData</varname> Parameter enthält ein Array von Spaltenschlüssel zu
Datenwerten. Die Methode gibt ein
<classname>Zend_Gdata_Spreadsheets_SpreadsheetsEntry</classname> Objekt zurück
welches die eingefügte Zeile repräsentiert.
</para>
<para>
Die Tabellenkalkulation fügt die neue Zeile unmittelbar nach der letzten Zeile ein
die in dem listen-basierenden Feed erscheint, was bedeutet unmittelbar vor der
ersten komplett leeren Zeile.
</para>
</sect3>
<sect3 id="zend.gdata.spreadsheets.listfeeds.editrow">
<title>Eine Zeile bearbeiten</title>
<para>
Sobald ein <classname>Zend_Gdata_Spreadsheets_ListEntry</classname> Objekt geholt
wird, können diese Zeilen durch die Verwendung der
<methodname>updateRow()</methodname> Methode des Tabellenkalkulations Services
aktualisiert werden.
</para>
<programlisting language="php"><![CDATA[
$updatedListEntry = $spreadsheetService->updateRow($oldListEntry,
$newRowData);
]]></programlisting>
<para>
Der <varname>$oldListEntry</varname> Parameter enthält den Listeneintrag der
aktualisiert werden soll. <varname>$newRowData</varname> enthält ein Array von
Spaltenschlüssel zu Datenwerten, die als neue Zeilendaten verwendet werden. Diese
Methode gibt ein <classname>Zend_Gdata_Spreadsheets_SpreadsheetsEntry</classname>
Objekt zurück welches die aktualisierte Zeile repräsentiert.
</para>
</sect3>
<sect3 id="zend.gdata.spreadsheets.listfeeds.deleterow">
<title>Eine Zeile löschen</title>
<para>
Um eine Zeile zu löschen muß einfach <methodname>deleteRow()</methodname> auf dem
<classname>Zend_Gdata_Spreadsheets</classname> Objekt mit dem bestehenden Eintrag
aufgerufen werden, der gelöscht werden soll:
</para>
<programlisting language="php"><![CDATA[
$spreadsheetService->deleteRow($listEntry);
]]></programlisting>
<para>
Alternativ kann die <methodname>delete()</methodname> Methode des Eintrags selbst
aufgerufen werden:
</para>
<programlisting language="php"><![CDATA[
$listEntry->delete();
]]></programlisting>
</sect3>
</sect2>
<sect2 id="zend.gdata.spreadsheets.cellfeeds">
<title>Mit zellen-basierenden Feeds interagieren</title>
<para>
In einem zellen-basierenden Feed repräsentiert jeder Eintrag eine einzelne Zelle.
</para>
<para>
Es wird nicht empfohlen mit beiden, einem zellen-basierenden Feed und einem
listen-basierenden Feed für das gleiche Arbeitsblatt zur selben Zeit zu interagieren.
</para>
<sect3 id="zend.gdata.spreadsheets.cellfeeds.get">
<title>Einen zellen-basierenden Feed erhalten</title>
<para>
Um einen Zellen Feed des Arbeitsblatt zu erhalten muß die
<methodname>getCellFeed()</methodname> Methode des Tabellenkalkulations Services
verwendet werden.
</para>
<programlisting language="php"><![CDATA[
$query = new Zend_Gdata_Spreadsheets_CellQuery();
$query->setSpreadsheetKey($spreadsheetKey);
$query->setWorksheetId($worksheetId);
$cellFeed = $spreadsheetService->getCellFeed($query);
]]></programlisting>
<para>
Im resultierenden <classname>Zend_Gdata_Spreadsheets_CellFeed</classname> Objekt
repräsentiert <varname>$cellFeed</varname> eine Antwort vom Server. Neben anderen
Dingen enthält dieser Feed ein Array von
<classname>Zend_Gdata_Spreadsheets_CellEntry</classname> Objekten
(<command>$cellFeed>entries</command>), von denen jeder eine einzelne Zelle in einem
Arbeitsblatt repräsentiert. Diese Information kann angezeigt werden:
</para>
<programlisting language="php"><![CDATA[
foreach($cellFeed as $cellEntry) {
$row = $cellEntry->cell->getRow();
$col = $cellEntry->cell->getColumn();
$val = $cellEntry->cell->getText();
echo "$row, $col = $val\n";
}
]]></programlisting>
</sect3>
<sect3 id="zend.gdata.spreadsheets.cellfeeds.cellrangequery">
<title>Eine Zellen-Bereichs Abfrage senden</title>
<para>
Angenommen man will die Zellen der ersten Spalte des Arbeitsblattes empfangen. Man
kann einen Zellen Feed abfragen der nur diese Spalte enthält und geht hierbei wie
folgt vor:
</para>
<programlisting language="php"><![CDATA[
$query = new Zend_Gdata_Spreadsheets_CellQuery();
$query->setMinCol(1);
$query->setMaxCol(1);
$query->setMinRow(2);
$feed = $spreadsheetService->getCellsFeed($query);
]]></programlisting>
<para>
Das fragt alle Daten in der Spalte 1, beginnend mit der Zeile 2, ab.
</para>
</sect3>
<sect3 id="zend.gdata.spreadsheets.cellfeeds.updatecell">
<title>Den Inhalt einer Zelle ändern</title>
<para>
Um den Inhalt einer Zelle zu ändern, muß <methodname>updateCell()</methodname> mit
der Zeile, Spalte und dem neuen Wert der Zelle, aufgerufen werden.
</para>
<programlisting language="php"><![CDATA[
$updatedCell = $spreadsheetService->updateCell($row,
$col,
$inputValue,
$spreadsheetKey,
$worksheetId);
]]></programlisting>
<para>
Die neuen Daten werden in der spezifizierten Zelle im Arbeitsblatt plaziert. Wenn
die spezifizierte Zelle bereits Daten enthält, werden diese überschrieben. Beachte:
<methodname>updateCell()</methodname> muß verwedet werden um Daten in einer Zelle zu
verändern, selbst wenn diese Zelle leer ist.
</para>
</sect3>
</sect2>
</sect1>