PHP code example of reandimo / google-sheets-helper
1. Go to this page and download the library: Download reandimo/google-sheets-helper 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/ */
reandimo / google-sheets-helper example snippets
use reandimo\GoogleSheetsApi\Helper;
// Set credentials via environment (recommended)
putenv('credentialFilePath=path/to/credentials.json');
putenv('tokenPath=path/to/token.json');
// Create instance and configure
$sheet = new Helper();
$sheet->setSpreadsheetId('your-spreadsheet-id');
$sheet->setWorksheetName('Sheet1');
// Read data
$sheet->setSpreadsheetRange('A1:D10');
$data = $sheet->get();
// Write data
$sheet->appendSingleRow(['Name', 'Email', 'Role']);
// Update a cell
$sheet->updateSingleCell('B2', '[email protected]');
> $sheet = new Helper('path/to/credentials.json', 'path/to/token.json');
>