PHPackages                             mechastorm/google-spreadsheet-exporter - 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. mechastorm/google-spreadsheet-exporter

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

mechastorm/google-spreadsheet-exporter
======================================

Libraries to deal with extracting data from a Google Spreadsheet and exporting it to another file format

1.0.0(12y ago)3351Apache-2.0PHPPHP &gt;=5.4.0

Since Jun 25Pushed 12y ago1 watchersCompare

[ Source](https://github.com/mechastorm/google-spreadsheet-exporter)[ Packagist](https://packagist.org/packages/mechastorm/google-spreadsheet-exporter)[ Docs](https://github.com/mechastorm/google-spreadsheet-exporter)[ RSS](/packages/mechastorm-google-spreadsheet-exporter/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (6)Versions (4)Used By (1)

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

[](#introduction)

The main functionality of this library focuses on the reading data from a Google Spreadsheet and outputting it into a readable file. Mostly for the purpose of localization and copy management, but can also be utilized for any other cases where one needs to transform data from Google Spreadsheet into another file format.

A sample of the sort spreadsheet it was made to read from can be seen [here](https://docs.google.com/a/mechaloid.com/spreadsheets/d/1GFQQ0clQRrYEM8_N0vyHeIIWqQdxJlbDe588uf_vlkU/edit#gid=0)

The libraries help with

- Read content from a Google Spreadsheet via a [service account](https://developers.google.com/drive/web/service-accounts)
- Transform that data. Currently only format is a hierarchical php array
- Writes that data into a file format. Currently supports a simple PHP file. Sample outputs can be seen at `examples/sample_ouput`

Framework Integrations
======================

[](#framework-integrations)

The library itself has been built to be framework agnostic (no framework dependencies). But some integration with existing framework examples

- On another package that I made, [Laravel Language Google Spreadsheet Importer](https://github.com/mechastorm/laravel-lang-google-spreadsheet-importer).

Background
==========

[](#background)

The aim is to

- Avoid hard coding copy text
- Reduce the dev cycle required when doing edits to copy text
- Nicely handle multiple translations of a copy text

This functionality was originally used at Nudge Social Media lead by @iskandar). This has proven to be really quick and handy way to let non-tech users write out some data into the ever familiar spreadsheet and for developers to extract that data in a readable format.

The original library heavily used [Zend\_Gdata](https://github.com/zendframework/ZendGData) to gain access to the Google Spreadsheet. Zend\_Gdata is no longer maintained and Google Apis are changing over to a new OAuth.

I wanted to use the Google Spreadsheet primarily for copy management and translations but had to use the newer Google APIs.

Todo
====

[](#todo)

- PhpUnit Tests
- Documentation
    - Contributing

Setup &amp; Installation
========================

[](#setup--installation)

Step 1. Get Your Google API Credentials
---------------------------------------

[](#step-1-get-your-google-api-credentials)

Go to  and create a new project.

Go into your project settings and click on left menu, "APIS &amp; AUTH" &gt; "APIS". Enable "Drive API".

Then click on left menu, "APIS &amp; AUTH" &gt; "Credentials", and click on "Create new Client ID". Select "Service Account" and generate your client ID.

[![Image](docs/google_api_credentials_screen.png?raw=true)](docs/google_api_credentials_screen.png?raw=true)

Your credentials would look something like

```
Client ID	            11111111111-abcdef.apps.googleusercontent.com
Email address	        11111111111-abcdef@developer.gserviceaccount.com
Public key fingerprints	1234567890
```

You will also have been prompted to download a p12 private key certificate (ie. 1234567890-privatekey.p12)

Step 2. Give Spreadsheet Access
-------------------------------

[](#step-2-give-spreadsheet-access)

We assume you have already set up your spreadsheet just like the [sample](https://docs.google.com/a/mechaloid.com/spreadsheets/d/1GFQQ0clQRrYEM8_N0vyHeIIWqQdxJlbDe588uf_vlkU/edit#gid=0)

**IMPORTANT**

At this point, the client email address should be the on you use to share your spreadsheet with.

You can give it view only access. Future updates may include updating the spreadsheet, which by that point, you will need to give edit access.

Configure Composer
------------------

[](#configure-composer)

Installation is primary via composer.

Create a composer.json file in your project and add the following:

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/mechastorm/google-spreadsheet-exporter.git"
        },
        {
            "type": "vcs",
            "url": "https://github.com/asimlqt/php-google-spreadsheet-client"
        }
    ],
    "require": {
        "mechastorm/google-spreadsheet-extractor": "dev-master"
    }
}
```

Usage Example
-------------

[](#usage-example)

If you are not using a PHP Framework or one that does not support autoloading, make sure to include the autoloader from composer.

A sample of this file can be seen at `examples/basic.php`. Let us assume you were using this [sample spreadsheet](https://docs.google.com/a/mechaloid.com/spreadsheets/d/1GFQQ0clQRrYEM8_N0vyHeIIWqQdxJlbDe588uf_vlkU/edit#gid=0)

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

use Mechastorm\Google\ApiHelper;
use Mechastorm\Google\Spreadsheet\Data\Exporter;
use Mechastorm\Google\Spreadsheet\Data\FormatWriters\LangPhpWriter;
use Mechastorm\Google\Spreadsheet\Data\Transformers\LocalePhpArray;

// Get the json encoded access token.
$authResponse = ApiHelper::getAuthByServiceAccount(
    array(
        'application_name' => 'name_of_application',
        'client_id' => 'service_account_client_id',
        'client_email' => 'service_account_client_email',
        'key_file_location' => 'location-to-your-private-key-p12-file', // This is the location of the P12 private key file you had donwloaded
    )
);
$accessToken = $authResponse->access_token;

echo 'Service Account Access Token: ' . $accessToken;

// Connect to the Google Spreadsheet
$gSSExporter = new Exporter(array(
    'access_token' => $accessToken,
    'spreadsheet_name' => 'google-spreadsheet-exporter Sample Spreadsheet' // It must match EXACTLY the name
));
$gSSExporter->setWorksheets();

// Instantiate a transformer
$transformer = new LocalePhpArray(array(
    'locales' => array(
        'en_GB', // Must match the columns on the spreadsheet
        'fr_CA',
        'my_MY',
        'ja_JP',
    ),
));

// Instantiate a write
$outputFolder = 'sample_output';
$writer = new LangPhpWriter(array(
    'path' => $outputFolder,
));

// Process the worksheets and output them to the desired format
$gSSExporter->processWorksheets(
    array(
        'Web Copy', // It must match EXACTLY the name
    ),
    $transformer,
    $writer
);

echo "Done - please check {$outputFolder} for the files\n";
```

Again sample outputs can be seen at `examples/sample_ouput`

Tests
=====

[](#tests)

Coming Up!

Contributors
============

[](#contributors)

- Shih Oon Liong (@mechastorm)

Credit
------

[](#credit)

- Iskandar Najmuddin([@iskandar](https://github.com/iskandar)) &amp; Matthew Long ([@matthewongithub](https://github.com/matthewongithub)) on the development of the original Kohana library that inspired this version

License
-------

[](#license)

Released under the [Apache 2.0 license](http://choosealicense.com/licenses/apache-2.0/).

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

4389d ago

Major Versions

0.1.0 → 1.0.02014-06-26

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1383297?v=4)[Shih Oon Liong](/maintainers/mechastorm)[@mechastorm](https://github.com/mechastorm)

---

Top Contributors

[![mechastorm](https://avatars.githubusercontent.com/u/1383297?v=4)](https://github.com/mechastorm "mechastorm (9 commits)")

---

Tags

phplocalizationgooglespreadsheet

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mechastorm-google-spreadsheet-exporter/health.svg)

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

###  Alternatives

[openspout/openspout

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

1.2k70.2M237](/packages/openspout-openspout)[alexandrainst/php-xlsx-fast-editor

PHP library to make basic but fast read &amp; write operations on existing Excel workbooks

1314.5k](/packages/alexandrainst-php-xlsx-fast-editor)

PHPackages © 2026

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