定制 sem-soft/google-sheets 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sem-soft/google-sheets

Composer 安装命令:

composer require sem-soft/google-sheets

包简介

Wrapper for working with Official Google Sheets API through Google Client Library

README 文档

README

This library implements basic functionality for writing data to Google Sheets document through Service Google Account.

Installation via composer.json

"sem-soft/google-sheets": "~1.0.0"

Usage

This library use the official Google Client package.

Auth by service aacount

Before use this library we must to configure basic Google Auth Client object for using service account credential file.

$auth = new \Sem\GoogleSheets\Auth\ServiceAccountAuthenticator();
$client = $auth->setAuth(new \Google_Client(), '/path/to/Credentials-5c2688ed460a.json');

Middleware objects

For writing process we must instantiate some basic objects. Book Object — entity of Google Spreadsheet. Sheet Object — entity of Google Spreadsheet sheet layer. This objects implemets current spreadsheet for writing process.

$book = new \Sem\GoogleSheets\Book('193J0l6pRREaQa5632PdD2sCioAJw5AxTV0TWnK0SNH7');
$sheet = new \Sem\GoogleSheets\Sheet('Лист 1');

Writer object

The writer object implements functionality for writing your data to cells, rows and clear ranges in sheets. This object is required book and sheet objects.

$writer = new \Sem\GoogleSheets\Writer(
    $client,
    $book,
    $sheet
);

Example for writing data to sheet of the book

$auth = new ServiceAccountAuthenticator();
$client = $auth->setAuth(new \Google_Client(), '/opt/Example-5c1111ed600a.json'));

$writer = new Writer(
    $client,
    new Book('193J0l6pRREaQa5632PdD2sCioAJw5AxTV0TWnK0SNH7'),
    new Sheet('Лист 1')
);
// Clear range
$writer->clearRange('A1:E100');
// Insert row of cells from A2
$writer->insertRow('A2', [
    'Раз',
    'Два',
    'Три'
]);
// Insert row of cells from A3
$writer->insertRow('A3', [
    'Четыри',
    'Пять',
    'Шесть'
]);
// Insert rows of cells from D column and 4 row
$writer->insertRows('D', 4, [
    [
        'Раз',
        'Два',
        'Три'
    ],
    [
        'Четыри',
        'Пять',
        'Шесть'
    ]
]);
// Set cell value
$writer->cell('D12', 'Привет!');

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2019-05-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固