1.64.1 (latest) 1.64.0 1.63.1 1.62.0 1.61.1 1.60.0 1.59.0 1.58.0 1.57.0 1.56.0 1.55.0 1.54.0 1.53.0 1.52.1 1.51.1 1.50.0 1.49.1 1.48.1 1.47.0 1.46.1 1.45.0 1.44.2 1.43.1 1.42.0 1.41.0 1.40.0 1.39.0 1.38.1 Reference documentation and code samples for the BigQuery API class Google::Cloud::Bigquery::External::SheetsSource.

## SheetsSource

[SheetsSource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-SheetsSource "Google::Cloud::Bigquery::External::SheetsSource (class)") is a subclass of [DataSource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource "Google::Cloud::Bigquery::External::DataSource (class)") and
represents a Google Sheets external data source that can be queried
from directly, even though the data is not stored in BigQuery. Instead
of loading or streaming the data, this object references the external
data source.

## Inherits

- [Google::Cloud::Bigquery::External::DataSource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource)

## Example

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

sheets_url = "https://docs.google.com/spreadsheets/d/1234567980"
sheets_table = bigquery.external sheets_url do |sheets|
  sheets.skip_leading_rows = 1
end

data = bigquery.query "SELECT * FROM my_ext_table",
                      external: { my_ext_table: sheets_table }

# Iterate over the first page of results
data.each do |row|
  puts row[:name]
end
# Retrieve the next page of results
data = data.next if data.next?
```

## Methods

### #range

    def range() -> String

Range of a sheet to query from. Only used when non-empty. Typical
format: `{sheet_name}!{top_left_cell_id}:{bottom_right_cell_id}`.
**Returns**

- (String) --- Range of a sheet to query from.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

sheets_url = "https://docs.google.com/spreadsheets/d/1234567980"
sheets_table = bigquery.external sheets_url do |sheets|
  sheets.range = "sheet1!A1:B20"
end

sheets_table.range #=> "sheet1!A1:B20"
```

### #range=

    def range=(new_range)

Set the range of a sheet to query from. Only used when non-empty.
Typical format:
`{sheet_name}!{top_left_cell_id}:{bottom_right_cell_id}`.
**Parameter**

- **new_range** (String) --- New range of a sheet to query from.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

sheets_url = "https://docs.google.com/spreadsheets/d/1234567980"
sheets_table = bigquery.external sheets_url do |sheets|
  sheets.range = "sheet1!A1:B20"
end

sheets_table.range #=> "sheet1!A1:B20"
```

### #skip_leading_rows

    def skip_leading_rows() -> Integer

The number of rows at the top of a sheet that BigQuery will skip
when reading the data. The default value is `0`.

This property is useful if you have header rows that should be
skipped. When `autodetect` is on, behavior is the following:

- `nil` - Autodetect tries to detect headers in the first row. If they are not detected, the row is read as data. Otherwise data is read starting from the second row.
- `0` - Instructs autodetect that there are no headers and data should be read starting from the first row.
- `N > 0` - Autodetect skips `N-1` rows and tries to detect headers in row `N`. If headers are not detected, row `N` is just skipped. Otherwise row `N` is used to extract column names for the detected schema.
**Returns**

- (Integer)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

sheets_url = "https://docs.google.com/spreadsheets/d/1234567980"
sheets_table = bigquery.external sheets_url do |sheets|
  sheets.skip_leading_rows = 1
end

sheets_table.skip_leading_rows #=> 1
```

### #skip_leading_rows=

    def skip_leading_rows=(row_count)

Set the number of rows at the top of a sheet that BigQuery will skip
when reading the data.
**Parameter**

- **row_count** (Integer) --- New skip_leading_rows value
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

sheets_url = "https://docs.google.com/spreadsheets/d/1234567980"
sheets_table = bigquery.external sheets_url do |sheets|
  sheets.skip_leading_rows = 1
end

sheets_table.skip_leading_rows #=> 1
```