Google API (Drive + Sheet)

Star-Dust

Expert
Licensed User
Longtime User
Last week a long-standing customer who recently created a sort of ERP on his own with APPSHEET using a GOOGLE SHEET document as a DB

The client asked me to develop an application that runs on his server and that absorbs data from a sheet contained within a Google SHEET document contained in Google Drive.
With this data I should create an EXCEL file and send it to a site with FTP and then modify the GOOGLE SHEET sheet to check the records of the sheet that I acquired and transferred as true.

So for the first time I started using the Google API and after going around the forum and doing a lot of trials and errors I produced my first library to access the Google API for DRIVE and SHEET. I used sources that are present on the forum such as the one by @Erel for access (Oaut2) and some other clips that I found adding the functions I needed for this job.

This is the result... NOW, i'm deciding whether or not to publish this library, whether it should be paid or free or simply share the sources... we'll see... For the moment it's in the testing phase

xSD_GoogleAPI

Author:
Star-Dust
Version: 1
  • GoogleAPI
    • Events:
      • DriveConnected (Success As Boolean)
      • FileDownloaded (Success As Boolean, NomeFile As String)
      • FileFound (id As String)
      • FileListResult (FileIDName As Map)
      • FileUploaded (id As String)
      • FolderCreated (id As String)
      • FolderFound (id As String)
      • TokenExpired
    • Fields:
      • mimeCSV As String
      • mimeEXCEL As String
      • mimeODS As String
      • OrientationColumn As String
      • OrientationRow As String
    • Functions:
      • Access (AutomaticReNewToken As Boolean) As ResumableSub
        <code> Wait For (Google.Access) COMPLETE (Success As Boolean) </code>
      • AppendSheetValue (spreadsheetid As String, sheetTitle As String, Range As String) As ResumableSub
      • Class_Globals As String
      • ConnectToDrive
        <code> Wait For Google_DriveConnectedConnected (Success As Boolean) </code>
      • CreateFolder (FolderName As String, ParentFolder As String)
      • Disconnect As String
        disconect
      • DownloadFile (FileID As String, LocalPath As String, LocalFilename As String)
        Download a file from Google Drive
        FileID : Is needed to download the correct file.
        LocalPath : Is all allowed excepted File.DirAssets
        LocalFilename : Name of the file. If the name should be the same like on Google Drive, pass with ""
        Event : FileDownloaded
      • ExportSheet (FileID As String, LocalPath As String, LocalFilename As String, mimeType As String)
        Export a doc from workspace Google to a file format
        FileID : Is needed to download the correct file.
        LocalPath : Is all allowed excepted File.DirAssets
        LocalFilename : Name of the file. If the name should be the same like on Google Drive, pass with ""
        mimeTyoe: Use conversion costant
        Event : FileDownloaded
      • FileList (parent As String)
        <code>WAIT FOR GA_FileListResult(FileIDName As Map)</code>
      • GetListSheets (spreadsheetid As String) As ResumableSub
        List of sheets - List of String
        <code>WAIT FOR (GetListSheets(spreadsheetid)) COMPLETE (ListSheet As List)</code>
      • GetSheet (spreadsheetid As String, sheetTitle As String) As ResumableSub
        Return rows of sheet - List of List
        <code>WAIT FOR (GetSheet(spreadsheetid, sheetTitle)) COMPLETE (ListOfRow As List)</code>
      • GetSheetRange (spreadsheetid As String, sheetTitle As String, Range As String) As ResumableSub
        return rows of sheet - List of List
        Range es. "R1C1:R2C2" (cells from Row 1 Col 1 to Row 2 Col 2 )
        Range es. "A1:B2" (cells from Row 1 Col 1 to Row 2 Col 2 )
        Range es. "A:A" (all cells col A)
        Range es. "A5:A" (all cells col A, from row 5)
        <code>WAIT FOR (GetSheetRange(spreadsheetid, sheetTitle, Range)) COMPLETE (ListOfRow As List)</code>
      • GoogleAccess As Boolean
      • Initialize (CallbackModule As Object, Eventname As String, YourClientID As String, YourClientSecret As String) As String
        Initializes the object. You can add parameters to this method if needed.
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • ReNewToken As String
      • ResetToken As String
        reset token
      • SearchForFileID (suchFile As String, parrent As String)
      • SearchForFolderID (suchFolder As String, parrent As String)
      • UpdateSheetValue (spreadsheetid As String, sheetTitle As String, Range As String, Orientation As String, values As Object()) As ResumableSub
        Range es. "A1:B2" or "R1C1:R2C2" (cells from Row 1 Col 1 to Row 2 Col 2 )
        Range es. "A:A" (all cells col A)
        values = Array (array As String("1","2") , Array as String("3","4") )
        <code>WAIT FOR (GetSheetRange(spreadsheetid, sheetTitle, Range)) COMPLETE (ListOfRow As List)</code>
      • UploadFile (Name As String, LocalDir As String, LocalFilename As String, Parent As String, FileId As String)
        Upload a file to Google Drive
        Name - The Name of the filename (Name at Google Drive)
        UploadDir - The (local) folder of the upload file.
        UploadFile - Filename (local) of the upload file
        FileID - The file ID on Google Drive. If not known, a new file will created.
        Events : FileUploadDone(FileID as string)
  • GoogleOAuth2
    • Events:
      • AccessTokenAvailable (Success As Boolean, Token As String)
      • TestFinish (Valid As Boolean, TestInformation As TokenInformation)
    • Functions:
      • Class_Globals As String
      • ClearToken As String
      • GetAccessToken As String
      • Initialize (Target As Object, EventName As String, ClientId As String, Scope As String, ClientSecret As String, DataFolder As String) As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • ReNewToken As String
      • ResetToken As String
      • TestConnect
      • WillExpire As Long
 
Last edited:

rabbitBUSH

Well-Known Member
Licensed User
NOW, i'm deciding whether or not to publish this library, whether it should be paid or free or simply share the sources... we'll see.
I don't envy you having to make that choice....

I do envy the skills in your mind - you continue to impress and bless us with your sharing.....so we don't mind if you put a price on this.....đź––đź‘Ť
 
Top