The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::Google::Spreadsheets - A Perl module for using Google Spreadsheets API.

SYNOPSIS

  use Net::Google::Spreadsheets;

  my $service = Net::Google::Spreadsheets->new(
    username => 'mygoogleaccount@example.com',
    password => 'mypassword'
  );

  my @spreadsheets = $service->spreadsheets();

  # find a spreadsheet by key
  my $spreadsheet = $service->spreadsheet(
    {
        key => 'key_of_a_spreasheet'
    }
  );

  # find a spreadsheet by title
  my $spreadsheet_by_title = $service->spreadsheet(
    {
        title => 'list for new year cards'
    }
  );

  # find a worksheet by title
  my $worksheet = $spreadsheet->worksheet(
    {
        title => 'Sheet1'
    }
  );

  # create a worksheet
  my $new_worksheet = $spreadsheet->add_worksheet(
    {
        title => 'Sheet2',
        row_count => 100,
        col_count => 3,
    }
  );

  # update cell by batch request
  $worksheet->batchupdate_cell(
    {row => 1, col => 1, input_value => 'name'},
    {row => 1, col => 2, input_value => 'nick'},
    {row => 1, col => 3, input_value => 'mail'},
    {row => 1, col => 4, input_value => 'age'},
  );

  # get a cell
  my $cell = $worksheet->cell({col => 1, row => 1});

  # update input value of a cell
  $cell->input_value('new value');

  # add a row
  my $new_row = $worksheet->add_row(
    {
        name => 'Nobuo Danjou',
        nick => 'lopnor',
        mail => 'nobuo.danjou@gmail.com',
        age  => '33',
    }
  );

  # fetch rows
  my @rows = $worksheet->rows;

  # or fetch rows with query
  
  @rows = $worksheet->rows({sq => 'age > 20'});

  # search a row
  my $row = $worksheet->row({sq => 'name = "Nobuo Danjou"'});

  # update content of a row
  $row->content(
    {
        nick => 'lopnor',
        mail => 'nobuo.danjou@gmail.com',
    }
  );

DESCRIPTION

Net::Google::Spreadsheets is a Perl module for using Google Spreadsheets API.

METHODS

new

Creates Google Spreadsheet API client. It takes arguments below:

username

Username for Google. This should be full email address format like 'mygoogleaccount@example.com'.

password

Password corresponding to the username.

source

Source string to pass to Net::Google::AuthSub.

spreadsheets(\%condition)

returns list of Net::Google::Spreadsheets::Spreadsheet objects. Acceptable arguments are:

title

title of the spreadsheet.

title-exact

whether title search should match exactly or not.

key

key for the spreadsheet. You can get the key via the URL for the spreadsheet. http://spreadsheets.google.com/ccc?key=key

spreadsheet(\%condition)

Returns first item of spreadsheets(\%condition) if available.

AUTHOR

Nobuo Danjou <nobuo.danjou@gmail.com>

SEE ALSO

http://code.google.com/intl/en/apis/spreadsheets/docs/2.0/developers_guide_protocol.html

http://code.google.com/intl/en/apis/spreadsheets/docs/2.0/reference.html

Net::Google::AuthSub

Net::Google::Spreadsheets::Spreadsheet

Net::Google::Spreadsheets::Worksheet

Net::Google::Spreadsheets::Cell

Net::Google::Spreadsheets::Row

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.