Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spreadsheet hyperlink value returning nil #10777

Open
alilland opened this issue Jul 1, 2022 · 2 comments
Open

spreadsheet hyperlink value returning nil #10777

alilland opened this issue Jul 1, 2022 · 2 comments

Comments

@alilland
Copy link

alilland commented Jul 1, 2022

The state of Arizona publishes a fishing report via Google Spreadsheets, each cell in column A contains hyperlinks to google maps which im trying to obtain
https://docs.google.com/spreadsheets/d/1m4X4I-fhhPL26jeLw4IlB4zG5dM5NgdN_6eewpbCgNM/edit#gid=1253509900

I am able to successfully read the text value, but unable to read the hyperlink value - its returning nil

p cell_data
#=> #<Google::Apis::SheetsV4::CellData:0x000000010d3a9040 @effective_value=#<Google::Apis::SheetsV4::ExtendedValue:0x000000010d3a1700 @string_value="   FOOLS HOLLOW LAKE">, @formatted_value="   FOOLS HOLLOW LAKE", @user_entered_value=#<Google::Apis::SheetsV4::ExtendedValue:0x000000010d4192f0 @string_value="   FOOLS HOLLOW LAKE">>

p cell_data.formatted_value
#=> "   FOOLS HOLLOW LAKE"

p cell_data.hyperlink
#=> nil

is there a way to get the hyperlink value? the clicked value is this

  • OS: MacOS
  • Ruby version: 3.1.2
@alilland
Copy link
Author

alilland commented Jul 8, 2022

Is this a limitation of the underlying REST API?

@drLoom
Copy link

drLoom commented Mar 17, 2024

@alilland ,
It is possible. You need to explicitly specify what data to fetch via fields key. Links for formatted text stored in textFormatRuns prop:

fields = 'sheets.data.rowData.values(userEnteredValue,textFormatRuns)'
ranges = ["Shhet1!A1"]

sheets_service.get_spreadsheet(spreadsheet_id, ranges:, fields:)

Tip: Use with include_grid_data set to true, #get_spreadsheet(spreadsheet_id, include_grid_data: true)
to get all data and then you can inspect result structure.

Tip2: To add data with formatted links see this stackoverflow answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants