PHPackages                             asimlqt/php-google-spreadsheet-client - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. asimlqt/php-google-spreadsheet-client

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

asimlqt/php-google-spreadsheet-client
=====================================

Google Spreadsheet PHP Client

v3.0.2(9y ago)5492.7M—2.6%150[43 issues](https://github.com/asimlqt/php-google-spreadsheet-client/issues)6Apache-2.0PHPPHP &gt;=5.6.0

Since Jul 28Pushed 6y ago40 watchersCompare

[ Source](https://github.com/asimlqt/php-google-spreadsheet-client)[ Packagist](https://packagist.org/packages/asimlqt/php-google-spreadsheet-client)[ Docs](https://github.com/asimlqt/php-google-spreadsheet-client)[ RSS](/packages/asimlqt-php-google-spreadsheet-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (31)Used By (6)

[![Build Status](https://camo.githubusercontent.com/0e822af068763b7251b83431437ff92f54dbc45999a28ae19145959a2664f606/68747470733a2f2f7472617669732d63692e6f72672f6173696d6c71742f7068702d676f6f676c652d73707265616473686565742d636c69656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/asimlqt/php-google-spreadsheet-client)

> ### This library is no longer maintained. Please use the official [Google PHP Client](https://developers.google.com/sheets/api/quickstart/php)
>
> [](#this-library-is-no-longer-maintained-please-use-the-official-google-php-client)

Contents
========

[](#contents)

- [Introduction](#introduction)
- [Installation](#installation)
- [Bootstrapping](#bootstrapping)
- [Spreadsheet](#spreadsheet)
    - [Retrieving a list of spreadsheets](#retrieving-a-list-of-spreadsheets)
    - [Retrieving a public spreadsheet](#retrieving-a-public-spreadsheet)
- [Worksheet](#worksheet)
    - [Retrieving a list of worksheets](#retrieving-a-list-of-worksheets)
    - [Adding a worksheet](#adding-a-worksheet)
    - [Adding headers to a new worksheet](#adding-headers-to-a-new-worksheet)
    - [Deleting a worksheet](#deleting-a-worksheet)
- [List feed](#list-feed)
    - [Retrieving a list feed](#retrieving-a-list-feed)
    - [Adding a list row](#adding-a-list-row)
    - [Updating a list row](#updating-a-list-row)
- [Cell feed](#cell-feed)
    - [Retrieving a cell feed](#retrieving-a-cell-feed)
    - [Updating a cell](#updating-a-cell)
- [Batch request](#updating-multiple-cells-with-a-batch-request)

Introduction
============

[](#introduction)

This library provides a simple interface to the Google Spreadsheet API v3.

There are a couple of important things to note.

- This library requires a valid OAuth access token to work but does not provide any means of generating one. The [Google APIs Client Library for PHP](https://github.com/google/google-api-php-client) has all the functionality required for generating and refreshing tokens so it would have been a waste of time duplicating the official Google library.
- You can not create spreadsheets using this library, as creating spreadsheets is not part of the Google Spreadsheet API, rather it's part of the Google Drive API. See the official [Google APIs Client Library for PHP](https://github.com/google/google-api-php-client).

I strongly recommend you read through the [official Google Spreadsheet API documentation](https://developers.google.com/google-apps/spreadsheets) to get a grasp of the concepts.

Usage
=====

[](#usage)

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

[](#installation)

Using [Composer](https://getcomposer.org/) is the recommended way to install it.

1 - Add "asimlqt/php-google-spreadsheet-client" as a dependency in your project's composer.json file.

```
{
    "require": {
        "asimlqt/php-google-spreadsheet-client": "3.0.*"
    }
}
```

2 - Download and install Composer.

```
curl -sS https://getcomposer.org/installer | php

```

3 - Install your dependencies.

```
php composer.phar install

```

4 - Require Composer's autoloader.

```
require 'vendor/autoload.php';

```

Bootstrapping
-------------

[](#bootstrapping)

The first thing you will need to do is initialize the service request factory:

```
use Google\Spreadsheet\DefaultServiceRequest;
use Google\Spreadsheet\ServiceRequestFactory;

$serviceRequest = new DefaultServiceRequest($accessToken);
ServiceRequestFactory::setInstance($serviceRequest);
```

> Note: For Windows users, you can disable the ssl verification by '$serviceRequest-&gt;setSslVerifyPeer(false)'

Spreadsheet
-----------

[](#spreadsheet)

### Retrieving a list of spreadsheets

[](#retrieving-a-list-of-spreadsheets)

```
$spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
$spreadsheetFeed = $spreadsheetService->getSpreadsheetFeed();
```

Once you have a SpreadsheetFeed you can iterate over the spreadsheets using a foreach loop by calling the 'getEntries()' method or you can retrieve a single spreadsheet by it's title.

```
$spreadsheet = $spreadsheetFeed->getByTitle('MySpreadsheet');
```

> Note: The 'getByTitle' method will return the first spreadsheet found with that title if you have more than one spreadsheet with the same name.

### Retrieving a public spreadsheet

[](#retrieving-a-public-spreadsheet)

A public spreadsheet is one that has been "published to the web". This does not require authentication. e.g.

```
$serviceRequest = new DefaultServiceRequest("");
ServiceRequestFactory::setInstance($serviceRequest);

$spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
$worksheetFeed = $spreadsheetService->getPublicSpreadsheet("spreadsheet-id");
```

The spreadsheet id can be copied from the url of the actual spreadsheet in Google Drive.

Worksheet
---------

[](#worksheet)

### Retrieving a list of worksheets

[](#retrieving-a-list-of-worksheets)

You can retrieve a list of worksheets from a spreadsheet by calling the getWorksheets() method.

```
$spreadsheet = $spreadsheetFeed->getByTitle('MySpreadsheet');
$worksheetFeed = $spreadsheet->getWorksheetFeed();
```

You can loop over each worksheet using 'getEntries()' or retrieve a single worksheet by it's title.

```
$worksheet = $worksheetFeed->getByTitle('Sheet1');
```

### Adding a worksheet

[](#adding-a-worksheet)

To create a new worksheet simply use the 'addWorksheet()' method. This takes 3 arguments:

- Worksheet name
- Number of rows
- Number of columns

```
$spreadsheet->addWorksheet('New Worksheet', 50, 20);
```

### Adding headers to a new worksheet

[](#adding-headers-to-a-new-worksheet)

The Google Spreadsheet API does not allow you to update a list row if headers are not already assigned. So, when you create a new worksheet, before you can add data to a worksheet using the 'Adding/Updating a list row' methods above, you need to add headers.

To add headers to a worksheet, use the following:

```
$cellFeed = $worksheet->getCellFeed();

$cellFeed->editCell(1,1, "Row1Col1Header");
$cellFeed->editCell(1,2, "Row1Col2Header");
```

The only required parameter is the worksheet name, The row and column count are optional. The default value for rows is 100 and columns is 10.

### Deleting a worksheet

[](#deleting-a-worksheet)

It's also possible to delete a worksheet.

```
$worksheet->delete();
```

List feed
---------

[](#list-feed)

List feeds work at the row level. Each entry will contain the data for a specific row.

> Note: You can not use formulas with the list feed. If you want to use formulas then you must use the cell feed (described below).

### Retrieving a list feed

[](#retrieving-a-list-feed)

```
$listFeed = $worksheet->getListFeed();
```

Once you have a list feed you can loop over each entry.

```
foreach ($listFeed->getEntries() as $entry) {
    $values = $entry->getValues();
}
```

The getValues() method returns an associative array where the keys are the column names and the values are the cell content.

> Note: The Google api converts the column headers to lower case so the column headings might not appear to be the same as what you see in Google Drive using your browser.

> Note: If there is data for a particular row which does not have a column header then Google randomly generates a header and as far as I know it always begins with an underscore. Bear in mind that this is not generated by this library.

You can also sort and filter the data so you only retrieve what is required, this is expecially useful for large worksheets.

```
$listFeed = $worksheet->getListFeed(["sq" => "age > 45", "reverse" => "true"]);
```

To find out all the available options visit [https://developers.google.com/google-apps/spreadsheets/#sorting\_rows](https://developers.google.com/google-apps/spreadsheets/#sorting_rows).

### Adding a list row

[](#adding-a-list-row)

```
$listFeed->insert(["name" => "Someone", "age" => 25]);
```

> When adding or updating a row the column headers need to match exactly what was returned by the Google API, not what you see in Google Drive.

### Updating a list row

[](#updating-a-list-row)

```
$entries = $listFeed->getEntries();
$listEntry = $entries[0];

$values = $listEntry->getValues();
$values["name"] = "Joe";
$listEntry->update($values);
```

Cell feed
---------

[](#cell-feed)

Cell feed deals with individual cells. A cell feed is a collection of cells (of type CellEntry)

### Retrieving a cell feed

[](#retrieving-a-cell-feed)

```
$cellFeed = $worksheet->getCellFeed();
```

### Updating a cell

[](#updating-a-cell)

You can retrieve a single cell from the cell feed if you know the row and column numbers for that specific cell.

```
$cell = $cellFeed->getCell(10, 2);
```

You can then update the cell value using the 'update' method. The value can be a primitive value or a formula e.g.

```
$cell->update("=SUM(B2:B9)");
```

### Updating multiple cells with a batch request

[](#updating-multiple-cells-with-a-batch-request)

When attempting to insert data into multiple cells then consider using the batch request functionality to improve performance.

To use the batch request functionality you need access to a cell feed first. You can not use batch requests with list feeds.

```
$cellFeed = $worksheet->getCellFeed();

$batchRequest = new Google\Spreadsheet\Batch\BatchRequest();
$batchRequest->addEntry($cellFeed->createCell(2, 1, "111"));
$batchRequest->addEntry($cellFeed->createCell(3, 1, "222"));
$batchRequest->addEntry($cellFeed->createCell(4, 1, "333"));
$batchRequest->addEntry($cellFeed->createCell(5, 1, "=SUM(A2:A4)"));

$batchResponse = $cellFeed->insertBatch($batchRequest);
```

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity64

Solid adoption and visibility

Community38

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 84.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 ~60 days

Recently: every ~180 days

Total

29

Last Release

2976d ago

Major Versions

1.0 → 2.0.02014-02-22

2.3.7 → 3.0.02016-04-02

v3.0.2 → v4.x-dev2018-03-25

PHP version history (2 changes)2.0.0PHP &gt;=5.3.0

3.0.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8d1ba605a0d5efec9649a10ac22f37d0c140e8ee928daac34686e987719bee17?d=identicon)[Asim](/maintainers/Asim)

---

Top Contributors

[![asimlqt](https://avatars.githubusercontent.com/u/1963846?v=4)](https://github.com/asimlqt "asimlqt (111 commits)")[![hectorbenitez](https://avatars.githubusercontent.com/u/1191281?v=4)](https://github.com/hectorbenitez "hectorbenitez (5 commits)")[![miku](https://avatars.githubusercontent.com/u/53705?v=4)](https://github.com/miku "miku (2 commits)")[![MarkMaldaba](https://avatars.githubusercontent.com/u/1492120?v=4)](https://github.com/MarkMaldaba "MarkMaldaba (2 commits)")[![markvds](https://avatars.githubusercontent.com/u/2143634?v=4)](https://github.com/markvds "markvds (1 commits)")[![mightymax](https://avatars.githubusercontent.com/u/1125773?v=4)](https://github.com/mightymax "mightymax (1 commits)")[![notprathap](https://avatars.githubusercontent.com/u/1151262?v=4)](https://github.com/notprathap "notprathap (1 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (1 commits)")[![SgtPooki](https://avatars.githubusercontent.com/u/1173416?v=4)](https://github.com/SgtPooki "SgtPooki (1 commits)")[![tandoan](https://avatars.githubusercontent.com/u/2153297?v=4)](https://github.com/tandoan "tandoan (1 commits)")[![tautelis](https://avatars.githubusercontent.com/u/6945396?v=4)](https://github.com/tautelis "tautelis (1 commits)")[![acairns](https://avatars.githubusercontent.com/u/705212?v=4)](https://github.com/acairns "acairns (1 commits)")[![UFOMelkor](https://avatars.githubusercontent.com/u/571106?v=4)](https://github.com/UFOMelkor "UFOMelkor (1 commits)")[![AustinW](https://avatars.githubusercontent.com/u/333398?v=4)](https://github.com/AustinW "AustinW (1 commits)")[![Brianmanden](https://avatars.githubusercontent.com/u/657246?v=4)](https://github.com/Brianmanden "Brianmanden (1 commits)")[![cornernote](https://avatars.githubusercontent.com/u/51875?v=4)](https://github.com/cornernote "cornernote (1 commits)")

---

Tags

googlespreadsheet

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/asimlqt-php-google-spreadsheet-client/health.svg)

```
[![Health](https://phpackages.com/badges/asimlqt-php-google-spreadsheet-client/health.svg)](https://phpackages.com/packages/asimlqt-php-google-spreadsheet-client)
```

###  Alternatives

[phpoffice/phpspreadsheet

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

13.9k293.5M1.3k](/packages/phpoffice-phpspreadsheet)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.2k57.6M131](/packages/openspout-openspout)[nuovo/spreadsheet-reader

Spreadsheet reader library for Excel, OpenOffice and structured text files

669863.2k8](/packages/nuovo-spreadsheet-reader)[avadim/fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP

2951.2M7](/packages/avadim-fast-excel-writer)[kartik-v/yii2-export

A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)

1623.1M35](/packages/kartik-v-yii2-export)[akeneo-labs/spreadsheet-parser

Akeneo Spreadsheet parser. Reads XLXS files from Microsoft Excel and Open Office

147598.3k6](/packages/akeneo-labs-spreadsheet-parser)

PHPackages © 2026

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