1. Go to this page and download the library: Download sem-soft/google-sheets library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sem-soft / google-sheets example snippets
$auth = new \Sem\GoogleSheets\Auth\ServiceAccountAuthenticator();
$client = $auth->setAuth(new \Google_Client(), '/path/to/Credentials-5c2688ed460a.json');
$book = new \Sem\GoogleSheets\Book('193J0l6pRREaQa5632PdD2sCioAJw5AxTV0TWnK0SNH7');
$sheet = new \Sem\GoogleSheets\Sheet('Лист 1');
$writer = new \Sem\GoogleSheets\Writer(
$client,
$book,
$sheet
);
$auth = new ServiceAccountAuthenticator();
$client = $auth->setAuth(new \Google_Client(), '/opt/Example-5c1111ed600a.json'));
$writer = new Writer(
$client,
new Book('193J0l6pRREaQa5632PdD2sCioAJw5AxTV0TWnK0SNH7'),
new Sheet('Лист 1')
);
// Clear range
$writer->clearRange('A1:E100');
// Insert row of cells from A2
$writer->insertRow('A2', [
'Раз',
'Два',
'Три'
]);
// Insert row of cells from A3
$writer->insertRow('A3', [
'Четыри',
'Пять',
'Шесть'
]);
// Insert rows of cells from D column and 4 row
$writer->insertRows('D', 4, [
[
'Раз',
'Два',
'Три'
],
[
'Четыри',
'Пять',
'Шесть'
]
]);
// Set cell value
$writer->cell('D12', 'Привет!');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.