|
NAMENet::Google::Spreadsheets - A Perl module for using Google Spreadsheets API.SYNOPSISuse 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 => 'danjou@soffritto.org', 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 => 'danjou@soffritto.org', } ); # delete the row $row->delete; # delete the worksheet $worksheet->delete; # create a table my $table = $spreadsheet->add_table( { worksheet => $new_worksheet, columns => ['name', 'nick', 'mail address', 'age'], } ); # add a record my $record = $table->add_record( { name => 'Nobuo Danjou', nick => 'lopnor', 'mail address' => 'danjou@soffritto.org', age => '33', } ); # find a record my $found = $table->record( { sq => '"mail address" = "danjou@soffritto.org"' } ); # delete it $found->delete; # delete table $table->delete; DESCRIPTIONNet::Google::Spreadsheets is a Perl module for using Google Spreadsheets API.METHODSnewCreates Google Spreadsheet API client. It takes arguments below:
spreadsheets(\%condition)returns list of Net::Google::Spreadsheets::Spreadsheet objects. Acceptable arguments are:
spreadsheet(\%condition)Returns first item of spreadsheets(\%condition) if available.AUTHORIZATIONSyou can optionally pass auth object argument when initializing Net::Google::Spreadsheets instance.If you want to use AuthSub mechanism, make Net::Google::DataAPI::Auth::AuthSub object and path it to the constructor: my $authsub = Net::Google::AuthSub->new; $authsub->auth(undef, $session_token); my $service = Net::Google::Spreadsheet->new( auth => $authsub ); In OAuth case, like this: my $oauth = Net::Google::DataAPI::Auth::OAuth->new( consumer_key => 'consumer.example.com', consumer_secret => 'mys3cr3t', callback => 'http://consumer.example.com/callback', ); $oauth->get_request_token; my $url = $oauth->get_authorize_token_url; # show the url to the user and get the $verifier value $oauth->get_access_token({verifier => $verifier}); my $service = Net::Google::Spreadsheet->new( auth => $oauth ); TESTINGTo test this module, you have to prepare as below.
AUTHORNobuo Danjou <danjou@soffritto.org>SEE ALSO<https://developers.google.com/google-apps/spreadsheets/>Net::Google::AuthSub Net::Google::DataAPI Net::OAuth Net::Google::Spreadsheets::Spreadsheet Net::Google::Spreadsheets::Worksheet Net::Google::Spreadsheets::Cell Net::Google::Spreadsheets::Row Net::Google::Spreadsheets::Table Net::Google::Spreadsheets::Record LICENSEThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |