1{-# LANGUAGE OverloadedStrings #-}
3module Example.Sheets where
5---------------------------------------------------------------------------------
6import Network.Google.Resource.Sheets.Spreadsheets.Get
7import Network.Google.Sheets
10import Control.Lens ((.~), (<&>))
11import Data.Text (Text)
12import System.IO (stdout)
13import Data.Aeson.Types
15---------------------------------------------------------------------------------
18-- This gets the Information about an spreadsheet.
19-- In order to be able to run these examples you need to
20-- create a service acount from google's developers console
21-- and copy the dowloaded json file to ~/.config/gcloud/application_default_credentials.json.
23-- you must also share with your service the spreadsheet that you want to get the info of.
24-- In order to do this you must share the sheet with the email address of your service
25-- which is in your downloaded service config file.
27-- after doing above step just pass the sreadsheet id to the function.
28exampleGetSheet :: Text -> IO Spreadsheet
29exampleGetSheet sheetID = do
30 lgr <- newLogger Debug stdout
31 env <- newEnv <&> (envLogger .~ lgr) . (envScopes .~ spreadsheetsScope)
32 runResourceT . runGoogle env $
33 send (spreadsheetsGet sheetID )
36-- you pass the sheet id and a range (eg. "sheet1!A1:C3") in that sheet
37-- and it retreives the values in the specified range
38exampleGetValue :: Text -> Text -> IO ValueRange
39exampleGetValue sheetID range = do
40 lgr <- newLogger Debug stdout
41 env <- newEnv <&> (envLogger .~ lgr) . (envScopes .~ spreadsheetsScope)
42 runResourceT . runGoogle env $
43 send (spreadsheetsValuesGet sheetID range )
46exampleAppendValue :: Text -> Text -> [[Value]] -> IO AppendValuesResponse
47exampleAppendValue sheetID range val = do
48 lgr <- newLogger Debug stdout
49 env <- newEnv <&> (envLogger .~ lgr) . (envScopes .~ spreadsheetsScope)
50 runResourceT . runGoogle env $
51 send (svaValueInputOption .~ Just "USER_ENTERED" $ spreadsheetsValuesAppend
53 ( vrMajorDimension .~ Just VRMDRows $ vrValues .~ val $ vrRange .~ Just range $ valueRange)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list