The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Google::RestApi::SheetsApi4::Spreadsheet - Represents a Google Spreadsheet.

DESCRIPTION

See the description and synopsis at Google::RestApi::SheetsApi4.

NAVIGATION

SUBROUTINES

new(%args);

Creates a new instance of a Spreadsheet object.

%args consists of:

  • sheets_api <SheetsApi4>: The parent SheetsApi4 object.

  • id <string>: The id of the spreadsheet (Google Drive file ID).

  • name <string>: The name of the spreadsheet (as shown in Google Drive).

  • title <string>: An alias for name.

  • uri <string>: The spreadsheet ID extracted from the overall URI.

  • cache_seconds <int>: Cache information for this many seconds (default to 5, 0 disables).

You would not normally call this directly, you would obtain it from the Sheets::open_spreadsheet routine.

Only one of id/name/title/uri should be specified and this API will derive the others as necessary.

The cache exists so that repeated calls for the same attributes or worksheet properties doesn't keep hammering the Google API over and over. The default is 5 seconds. See 'cache_seconds' below.

api(%args);

Calls the parent SheetsApi4's 'api' routine adding the sheet file ID, and passing through any args such as content, params, headers, etc.

You would not normally call this directly unless you were making a Google API call not currently supported by this API framework.

Returns the response hash from Google API.

spreadsheet_id();

Returns the spreadsheet id (the Google Drive file id).

spreadsheet_uri();

Returns the URI of this spreadsheet.

spreadsheet_name();

Returns the name of the spreadsheet.

spreadsheet_title();

An alias for 'spreadsheet_name'.

attrs(fields<string>);

Returns the spreadsheet attributes of the specified fields.

properties(properties<string>);

Returns the spreadsheet property attributes of the specified fields.

worksheet_properties(what<string>);

Returns an array ref of the properties of the worksheets owned by this spreadsheet.

cache_seconds(seconds<int>)

Sets the caching time in seconds. Calling will always delete the existing cache. 0 disables the cache (not recommended).

delete_all_protected_ranges();

Deletes all the protected ranges from all the worksheets owned by this spreadsheet.

named_ranges(name<string>);

Returns the properties of the named range passed, or if false is passed, all the named ranges for this spreadsheet.

copy_spreadsheet(%args);

Creates a copy of this spreadsheet and passes any args to the Google Drive file copy routine.

delete_spreadsheet();

Deletes this spreadsheet from Google Drive.

range_group(range<array>...);

Creates a range group with the contained ranges. See the RangeGroup object.

tie(%args);

%args is a hash of key => Range object pairs.

Ties the given 'key => range' pairs into a tied range group. The range group can be used to send batch values (API batchUpdate) and batch requests (API batchRequests) as a single call once all the changes have been made to the overall hash.

Turning on the 'fetch_range' property will return the underlying ranges on fetch so that formatting for the ranges can be set. You would normally only turn this on for a short time, and turn it off when the underlying batch requests have been submitted.

 $tied = $ss->tie(id => $range_cell);
 tied(%$tied)->fetch_range(1);
 $tied->{id}->bold()->red()->background_blue();
 tied(%$tied)->fetch_range(0)->submit_requests();

See also Worksheet::tie.

submit_values(%args);

%args consists of:

  • ranges <arrayref>: The ranges that have requests to be sent in one batchUpdate Google API call.

  • content <hashref>: Any additional content to be sent to the Google API for this batch submit, for any customized content that needs to be passed.

Submits the batch values (Google API's batchUpdate) for the specified ranges. Content is passed to the SheetsApi4's 'api' call for any customized content you may need to pass.

submit_requests(%args);

%args consists of:

  • ranges <arrayref>: The ranges that have requests to be sent in one batchRequest Google API call.

  • content <hashref>: Any additional content to be sent to the Google API for this batch submit, for any customized content that needs to be passed.

Submits the batch requests (Google API's batchRequest) for the specified ranges. Content is passed to the SheetsApi4's 'api' call for any customized content you may need to pass.

protected_ranges();

Returns all the protected ranges for this spreadsheet.

open_worksheet(%args);

Creates a new Worksheet object, passing the args to that object's 'new' routine (which see).

sheets_api();

Returns the SheetsApi4 object.

AUTHORS

  • Robin Murray mvsjes@cpan.org

COPYRIGHT

Copyright (c) 2021, Robin Murray. All rights reserved.

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