PHPackages                             reandimo/google-sheets-helper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. reandimo/google-sheets-helper

ActiveLibrary[API Development](/categories/api)

reandimo/google-sheets-helper
=============================

A bunch of functions to work easily with Google Sheets API

v1.2.0(11mo ago)0780[1 issues](https://github.com/reandimo/php-google-sheets-helper/issues)MITPHPPHP &gt;=5.4.0CI passing

Since Feb 18Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/reandimo/php-google-sheets-helper)[ Packagist](https://packagist.org/packages/reandimo/google-sheets-helper)[ Docs](https://github.com/reandimo/google-sheets-helper)[ RSS](/packages/reandimo-google-sheets-helper/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (12)Used By (0)

PHP Google Sheets Helper
========================

[](#php-google-sheets-helper)

### A powerful, elegant wrapper around Google Sheets API for PHP

[](#a-powerful-elegant-wrapper-around-google-sheets-api-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/ec64d7f4fbe486ad89d698e479d9e20c31089c78ccb2c3a5f6c39c17e07296c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7265616e64696d6f2f676f6f676c652d7368656574732d68656c7065723f7374796c653d666f722d7468652d626164676526636f6c6f723d626c7565)](https://packagist.org/packages/reandimo/google-sheets-helper)[![License](https://camo.githubusercontent.com/6f243faf0b9fe45620d632e8899b34b7e24e7a0b46cf27d7dbf0f3b921789a79/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7265616e64696d6f2f676f6f676c652d7368656574732d68656c7065723f7374796c653d666f722d7468652d626164676526636f6c6f723d677265656e)](https://packagist.org/packages/reandimo/google-sheets-helper)[![PHP Version](https://camo.githubusercontent.com/f9ea0ae1c508aba0db825eeb16b4b4b5315cb78f057638259f69af869efdd919/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f7265616e64696d6f2f676f6f676c652d7368656574732d68656c7065722f7068703f7374796c653d666f722d7468652d626164676526636f6c6f723d707572706c65)](https://packagist.org/packages/reandimo/google-sheets-helper)[![Downloads](https://camo.githubusercontent.com/3d728804521543cd03ce0b3ef8a48b36c9b61dd256963346e6ed59daf88eb4cd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7265616e64696d6f2f676f6f676c652d7368656574732d68656c7065723f7374796c653d666f722d7468652d626164676526636f6c6f723d6f72616e6765)](https://packagist.org/packages/reandimo/google-sheets-helper)

[Installation](#-installation) • [Quick Start](#-quick-start) • [API Reference](#-api-reference) • [Tips](#-tips) • [License](#-license)

---

Stop wrestling with the verbose Google Sheets API. This library wraps the official [Google APIs Client Library for PHP](https://github.com/googleapis/google-api-php-client) into a clean, fluent interface so you can **read, write, and manage spreadsheets** in just a few lines of code.

Features
--------

[](#features)

FeatureDescription**Read**`get()` `getSingleCellValue()` `findCellByValue()`Fetch ranges, single cells, or search by value**Write**`appendSingleRow()` `append()` `updateSingleCell()` `update()`Append rows, update cells or entire ranges**Sheets**`addWorksheet()` `duplicateWorksheet()` `renameWorksheet()` `deleteWorksheet()`Full worksheet lifecycle management**Style**`colorRange()` `clearRange()`Color cells and clear data**Manage**`create()` `getSpreadsheetWorksheets()`Create spreadsheets and list worksheets---

Requirements
------------

[](#requirements)

- PHP &gt;= 5.4 with CLI and JSON extension
- A [Google Cloud Platform](https://console.cloud.google.com/) project with the **Sheets API** enabled
- Credentials (`credentials.json`) from the Google Cloud Console

---

Installation
------------

[](#installation)

```
composer require reandimo/google-sheets-helper
```

---

Credentials Setup
-----------------

[](#credentials-setup)

The library authenticates using two files: `credentials.json` (from Google Cloud Console) and `token.json` (generated on first auth).

Generate `token.json` by running from your project root:

```
php ./vendor/reandimo/google-sheets-helper/firstauth
```

Follow the interactive steps — this only needs to be done once.

See it in action
 [![firstauth terminal preview](docs/terminal-preview.svg)](docs/terminal-preview.svg)

---

Quick Start
-----------

[](#quick-start)

```
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', 'john@example.com');
```

> You can also pass credential paths directly to the constructor:
>
> ```
> $sheet = new Helper('path/to/credentials.json', 'path/to/token.json');
> ```

---

API Reference
-------------

[](#api-reference)

### Reading Data

[](#reading-data)

#### `get()` — Get values from a range

[](#get--get-values-from-a-range)

```
$sheet->setSpreadsheetRange('A1:C10');
$data = $sheet->get();
```

#### `getSingleCellValue(string $cell)` — Get a single cell value

[](#getsinglecellvaluestring-cell--get-a-single-cell-value)

```
$value = $sheet->getSingleCellValue('B2');
echo "Value: $value\n";
```

#### `findCellByValue(string $searchValue)` — Search for a value

[](#findcellbyvaluestring-searchvalue--search-for-a-value)

```
$sheet->setSpreadsheetRange('A1:Z100');
$result = $sheet->findCellByValue('searchValue');

if ($result) {
    echo "Found at {$result['cell']} (row {$result['row']}, col {$result['column']})\n";
}
```

---

### Writing Data

[](#writing-data)

#### `appendSingleRow(array $row)` — Append one row

[](#appendsinglerowarray-row--append-one-row)

```
$sheet->setSpreadsheetRange('A1:C1');
$inserted = $sheet->appendSingleRow(['John', 'john@doe.com', 'Admin']);

if ($inserted >= 1) {
    echo 'Row inserted.';
}
```

#### `append(array $rows)` — Append multiple rows

[](#appendarray-rows--append-multiple-rows)

```
$sheet->setSpreadsheetRange('A1:C1');
$sheet->append([
    ['Alice', 'alice@example.com', 'Editor'],
    ['Bob',   'bob@example.com',   'Viewer'],
    ['Carol', 'carol@example.com', 'Admin'],
]);
```

#### `updateSingleCell(string $cell, mixed $value)` — Update one cell

[](#updatesinglecellstring-cell-mixed-value--update-one-cell)

```
$update = $sheet->updateSingleCell('B5', 'Updated value');

if ($update->getUpdatedCells() >= 1) {
    echo 'Cell updated.';
}
```

#### `update(array $values)` — Update a range

[](#updatearray-values--update-a-range)

```
$sheet->setSpreadsheetRange('A1:C3');
$update = $sheet->update([
    ['val1', 'val2', 'val3'],
    ['val4', 'val5', 'val6'],
    ['val7', 'val8', 'val9'],
]);

if ($update->getUpdatedCells() >= 1) {
    echo 'Range updated.';
}
```

---

### Worksheet Management

[](#worksheet-management)

#### `getSpreadsheetWorksheets()` — List all worksheets

[](#getspreadsheetworksheets--list-all-worksheets)

```
$worksheets = $sheet->getSpreadsheetWorksheets();

foreach ($worksheets as $ws) {
    echo "ID: {$ws['id']}, Title: {$ws['title']}\n";
}
```

#### `addWorksheet(string $title, int $rows, int $cols)` — Create a new worksheet

[](#addworksheetstring-title-int-rows-int-cols--create-a-new-worksheet)

```
$newSheetId = $sheet->addWorksheet('NewSheet', 100, 10);
echo "Created worksheet ID: $newSheetId\n";
```

#### `duplicateWorksheet(string $newName)` — Duplicate a worksheet

[](#duplicateworksheetstring-newname--duplicate-a-worksheet)

```
$sheet->setWorksheetName('Sheet1');
$sheetId = $sheet->duplicateWorksheet('Sheet1 - Copy');

if ($sheetId) {
    echo 'Worksheet duplicated.';
}
```

#### `renameWorksheet(string $oldName, string $newName)` — Rename a worksheet

[](#renameworksheetstring-oldname-string-newname--rename-a-worksheet)

```
$sheet->renameWorksheet('OldName', 'NewName');
```

#### `deleteWorksheet(string $name)` — Delete a worksheet

[](#deleteworksheetstring-name--delete-a-worksheet)

```
$deleted = $sheet->deleteWorksheet('SheetToDelete');

if ($deleted) {
    echo 'Worksheet deleted.';
}
```

---

### Styling &amp; Utilities

[](#styling--utilities)

#### `colorRange(array $rgb)` — Set background color

[](#colorrangearray-rgb--set-background-color)

```
$sheet->setSpreadsheetRange('A1:Z10');
$sheet->colorRange([142, 68, 173]); // Purple background
```

#### `clearRange()` — Clear all values in a range

[](#clearrange--clear-all-values-in-a-range)

```
$sheet->setSpreadsheetRange('A1:Z100');
$sheet->clearRange();
```

#### `create(string $title)` — Create a new spreadsheet

[](#createstring-title--create-a-new-spreadsheet)

```
$newId = $sheet->create('My New Spreadsheet');
echo "Spreadsheet ID: $newId\n";
```

#### `Helper::getColumnLettersIndex(string $letters)` — Column letter to index

[](#helpergetcolumnlettersindexstring-letters--column-letter-to-index)

```
Helper::getColumnLettersIndex('AZ'); // Returns 52
```

---

Tips
----

[](#tips)

> **Blank cells on insert/update:** Use the constant `Google_Model::NULL_VALUE` to represent an empty cell.
>
> ```
> $sheet->appendSingleRow([
>     'John Doe',
>     'john@doe.com',
>     Google_Model::NULL_VALUE, // skip this cell
>     'Sagittarius',
> ]);
> ```

> **Multiple sheet instances:** Create as many `Helper` instances as you need to work with different spreadsheets or worksheets simultaneously.
>
> ```
> $orders = new Helper();
> $orders->setSpreadsheetId('spreadsheet-a');
> $orders->setWorksheetName('Orders');
>
> $inventory = new Helper();
> $inventory->setSpreadsheetId('spreadsheet-b');
> $inventory->setWorksheetName('Stock');
> ```

---

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

Questions &amp; Issues
----------------------

[](#questions--issues)

Found a bug or have a suggestion? [Open an issue](https://github.com/reandimo/google-sheets-helper/issues).

Author
------

[](#author)

**Renan Diaz** — Working with PHP since 2017 &amp; Google's API since 2019.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance73

Regular maintenance activity

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~173 days

Recently: every ~302 days

Total

8

Last Release

337d ago

Major Versions

v0.1.4 → v1.0.02022-10-12

PHP version history (2 changes)0.1.0PHP &gt;=7.4

v0.1.3PHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab7b80fb0a9fdd67f0a13a2ff509499742bd5c8a00201f0ad1b7a68241493306?d=identicon)[reandimo](/maintainers/reandimo)

---

Top Contributors

[![reandimo](https://avatars.githubusercontent.com/u/22597970?v=4)](https://github.com/reandimo "reandimo (40 commits)")[![gabogalt](https://avatars.githubusercontent.com/u/47416463?v=4)](https://github.com/gabogalt "gabogalt (7 commits)")

---

Tags

apiexcelgooglegoogle-sheetsgoogle-sheets-apigoogle-sheets-api-v4phpspreadsheetsphpgoogleexcelspreadsheetsheetspreadsheet helper

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/reandimo-google-sheets-helper/health.svg)

```
[![Health](https://phpackages.com/badges/reandimo-google-sheets-helper/health.svg)](https://phpackages.com/packages/reandimo-google-sheets-helper)
```

###  Alternatives

[google-gemini-php/client

Gemini API is a supercharged PHP API client that allows you to interact with the Gemini API

402986.7k21](/packages/google-gemini-php-client)[jeroendesloovere/geolocation-php-api

This Geolocation PHP class connects to Google Maps API to find latitude/longitude or address.

75316.8k4](/packages/jeroendesloovere-geolocation-php-api)[x-fran/g-trends

Google Trends API for PHP

11955.6k](/packages/x-fran-g-trends)[aurawindsurfing/google-translate

Free Laravel package for Paid Google Translate REST API with your own API key

1119.5k1](/packages/aurawindsurfing-google-translate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
