-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo.scala
More file actions
30 lines (21 loc) · 1.04 KB
/
Demo.scala
File metadata and controls
30 lines (21 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import com.colisweb.gdrive.client._
import com.colisweb.gdrive.client.drive.{GoogleDriveClient, GoogleDriveRole}
import com.colisweb.gdrive.client.sheets.{GoogleSheetClient, GoogleSheetProperties, SheetRangeContent}
import scala.jdk.CollectionConverters._
object Demo extends App {
val sheetId = "1R_rshsVSQkfehwP-4R_Fb2f5Ilgwjeu-nzxvStSPRg8"
val authenticator = GoogleAuthenticator.fromResource("google-credentials.json", Some("RoutingAnalysis"))
val drive = new GoogleDriveClient(authenticator)
val sheets = new GoogleSheetClient(authenticator)
val spreadsheetId = sheets.createSpreadsheet("spreadsheet_name", List(GoogleSheetProperties("foo")))
println(spreadsheetId)
val rows = sheets
.readRows(spreadsheetId, List("A1:C2", "A2:D3"))
.flatten
.map(_.getValues.asScala.toList)
.map(_.map(_.getFormattedValue))
.toList
rows.foreach(println)
sheets.writeRange(spreadsheetId, SheetRangeContent("G1:H4", rows.transpose))
drive.share(spreadsheetId, "michel.daviot@colisweb.com", GoogleDriveRole.commenter)
}