Google Sheet API Wrapper for Laravel. Easiest way to interact with your sheet.
- Create a Google Cloud project. If you want to use your existing project, you can jump to the next step.
- Create Service Acount Credentials on Google Developer Console and share your Google Sheet file to these service account email.
- Place your downloaded service account json file to
storage/app/google-sheet/
folder, then rename these file tocredentials.json
. - Enable
Google Sheet API
on Google Workspace APIs.
You can install the package via composer:
composer require ibnuhalimm/laravel-google-sheet
Optionally, you can publish the config file of this package with this command:
php artisan vendor:publish --provider="Ibnuhalimm\LaravelGoogleSheet\GoogleSheetServiceProvider"
or by mention the config tag
php artisan vendor:publish --tag=google-sheet-config
You can use GoogleSheet
facade (the alias or class itself).
use GoogleSheet;
$spreadSheetId = '1cyUalLbuw_TpAIgkf76JcU-BbsYCSwtVqJuf_gCNzYA';
$sheetName = 'Class Data';
$cellRange = 'A1:E5';
GoogleSheet::useDocument($spreadSheetId)->fetchData($sheetName, $cellRange);
This method will returns the subset of array data
=> [
[
"Student Name",
"Gender",
"Class Level",
"Home State",
"Major",
],
[
"Alexandra",
"Female",
"4. Senior",
"CA",
"English",
],
...
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected]
instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.