Code Monkey home page Code Monkey logo

instant-googlespreadsheet-output's Introduction

instant-googlespreadsheet-output

PHPからさくっとGoogleSpreadSheetを新規作成してデータの挿入をやるやつ

動機

Webシステムの集計データとか調査データをさくっと他の人に共有したいときにスプレッドシートに直で吐き出したら楽だと思ったので。

スプレッドシートに吐き出すライブラリはあるにはあるけど、先に手動でシートを作ってからみたいのが多くて、欲しかったのはデータの配列突っ込んだらスプレッドシートのURLを返すというそれだけのシンプルなものなので作りました。

いつのまにかGoogleAnalyticsで集計データのアウトプット先にスプレッドシートが追加されていて、便利だなーと思ったのが発端です。(以前はCSVダウンロードとかだけだった気がします。)

準備

GoogleApisのサービスアカウントが必要(そのうち書く)

使い方

install

composer require egapool/instant-googlespreadsheet-output
<?php

require_once __DIR__.'/vendor/autoload.php';
use InstantGoogleSpreadSheetOutput\Outputer;

$data = [
	['日','月','火','水','木','金','土'],
	['あれ','これ','それ','これ?','どれ?','それ','えっ'],
];

// create instanse
$outputer = new Outputer('/path/to/youre/spreadsheet-xxxxxxxxx.json');

// create new SpreadSheet
$outputer
	->creatSheet('シートのタイトル') // create new SpreadSheet with title word
	->write($data) // insert data
	->attatchAuthToUser('test[at]gmail.com'); // permit others to access this sheet

echo $outputer->spreadsheet->spreadsheetUrl;

やること

  • リポジトリ名がなんかださい

instant-googlespreadsheet-output's People

Contributors

egapool avatar

Watchers

 avatar

instant-googlespreadsheet-output's Issues

渡す配列が正の整数ではないキーを含んでいるとエラー

Uncaught exception Google_Service_Exception: {
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Unknown name \"id\" at 'data[0].values[0]': Cannot find field.\nInvalid JSON payload received. Unknown name \"name\" at 'data[0].values[0]': Cannot find field.",
    "errors": [
      {
        "message": "Invalid JSON payload received. Unknown name \"id\" at 'data[0].values[0]': Cannot find field.\nInvalid JSON payload received. Unknown name \"name\" at 'data[0].values[0]': Cannot find field.",
        "domain": "global",
        "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.