使用Zend Gdata在Google电子表格中插入标题行

时间:2013-08-01 10:19:50

标签: zend-framework google-sheets gdata google-spreadsheet-api zend-gdata

我正在使用Zend Gdata在Google电子表格中创建工作表。 因为我在我新创建的工作表中存储数据,所以我以编程方式设置列的标题。

$headers = array(
    'Nom',
    'Prénom',
    'Entreprise/Organisation',
    'Fonction',
    'Adresse e-mail',
    'Téléphone',
    'Connu par'
);

foreach ($headers as $k => $col) {
    $connect->updateCell(1, $k+1, htmlspecialchars($col), $spreadsheet_id, $worksheet_id);
}

$headers = $connect->insertRow(
    array(
        htmlspecialchars('nom') => 'SKLI',
        htmlspecialchars('prénom') => 'Pierre',
        htmlspecialchars('entrepriseorganisation') => 'mosaika',
        htmlspecialchars('fonction') => 'ceo',
        htmlspecialchars('adressee-mail') => 'ble@ble.com',
        htmlspecialchars('téléphone') => '00 43 08 03 23',
        htmlspecialchars('connupar') => 'ble'
    ),
    $spreadsheet_id,
    $worksheet_id
);

正如您所看到的,我正在使用updateCell()方法首先定义我的标题列,然后使用insertRow()来填充数据列。当我执行我的代码并查看Google云端硬盘中的开放电子表格时,我可以看到updateCell()被迭代并且列标题是一个接一个地创建的,而数据行(带有insertRow())会立即添加,行按行。

是否有另一种更快的方法来“立即”定义标题列,就像使用insertRow()而不是逐个创建标题列一样?

谢谢!

0 个答案:

没有答案