PHP code example of holoolaz / sheets2api

1. Go to this page and download the library: Download holoolaz/sheets2api 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/ */

    

holoolaz / sheets2api example snippets

vendor/autoload.php



use GoogleSheets2API\Sheets2API\Sheets2API;

$sheets2api = new Sheets2API('YOUR_API_ID_HERE');

$params = [
	'limit' => 2,
	'orderBy' => 'Id',
	'order' => 'DESC'
];

$response = $sheets2api->Sheet('Sheet1')->get($params);
print_r($response);

$params = [
	'limit' => 2,
	'orderBy' => 'Id',
	'order' => 'DESC'
];

$response = $sheets2api->Spreadsheet()->get($params);
print_r($response);

$response = $sheets2api->Spreadsheet()->count();

$response = $sheets2api->Sheet('Sheet1')->count();   

$response = $sheets2api->Spreadsheet()->keys(); 

$response = $sheets2api->Sheet('Sheet1')->keys();   

$query = ['ranger', 'brad'];
$params = [
	'limit' => 3,
	'orderBy' => 'Id',
	'order' => 'DESC',
	'caseSensitive' => 'true'
];

$response = $sheets2api->Spreadsheet()->search($query);

$response = $sheets2api->Sheet('Sheet1')->search($query);   

$query = ['Name' => 'brad']

$response = $sheets2api->Spreadsheet()->searchBy($query);

$response = $sheets2api->Sheet('Sheet1')->searchBy($query); 

$response = $sheets2api->Spreadsheet()->sheets();

$response = $sheets2api->Spreadsheet()->name();

$response = $sheets2api->Spreadsheet()->list();

$response = $sheets2api->Sheet('Sheet3')->copy('SPREADSHEET_ID_TO_COPY_DATA_TO');
$response = $sheets2api->Sheet('Sheet3')->copy('1t59SEiPQtySWFwwBEzP5jcgmX18Ywc5ytYiitJYxbY8');

$data = ['6', 'john', '[email protected]', 'Slovakia'];
$response = $sheets2api->Spreadsheet()->addRow($data);
$response = $sheets2api->Sheet('Sheet3')->addRow($data);

$data = [
	array('6', 'john', '[email protected]', 'Slovakia'),
	array('7', 'jack', '[email protected]', 'Brazil')
];
$response = $sheets2api->Spreadsheet()->addRows($data);
$response = $sheets2api->Sheet('Sheet3')->addRows($data);

$response = $sheets2api->SpreadSheet()->create('NEW_SHEET');

$url = 'URL_TO_IMPORT_FROM';
$index = 1;

$response = $sheets2api->Sheet('Sheet26')->importTable($url, $index);

$url = 'URL_TO_IMPORT_FROM';
$index = 1;

$response = $sheets2api->Sheet('Sheet26')->importList($url, $index);