0
0

More than 1 year has passed since last update.

RubyでGoogleSpreadSheetのハイパーリンクの値を取る

Posted at

セルの値は割と簡単にとれるし、公式でもコードが例示されているのでやりやすい。
ただ、セルの情報を取ろう(例えばハイパーリンク)とするとそのままだとダメだった。

よくある例(というか公式)

だいたいservice.get_spreadsheet_values spreadsheet_id, rangeで値を取る例が多い。
これだと拡張属性取れない。

pythonだと…

https://stackoverflow.com/questions/46879715/get-hyperlink-from-a-cell-in-google-sheet-api-v4
こんなのが見つかったので、rubyでどう書くか調べる。

rubydoc

https://googleapis.dev/ruby/google-api-client/latest/Google/Apis/SheetsV4/SheetsService.html#get_spreadsheet-instance_method
これが対応するメソッドのようだ。
(メソッド名だけだとセル取るのかわからないが…)

https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get
ちなみにAPIのほうはこれ。Rubyのサンプル適当かよ…

最終的に

response = service.get_spreadsheet(SPREAD_SHEET_ID, fields: "sheets/data/rowData/values/hyperlink", ranges: "A1:B2")
みたいになる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0