activities
latest
false
UiPath logo, featuring letters U and I in white
Productivity Activities
Last updated Nov 6, 2024

Google Sheets APIs

Creates a Google Sheets service.

Namespace: UiPath.Gsuite.Activities.API

Assembly: UiPath.Gsuite.Activities.API (in UiPath.Gsuite.Activities.API.dll)

Constructors

ConstructorDescriptionSyntax
GoogleSheetsServiceInitializes a new instance of the GoogleSheetsService class
public class GoogleSheetsService : IGoogleSheetsServicepublic class GoogleSheetsService : IGoogleSheetsService

Methods

Name

Description
Adds a new sheet to the specified spreadsheet.
Creates a new spreadsheet.
DeleteColumnDelete a specified column from a sheet or range. The column on the right of the deleted column is then shifted to the left.
Deletes a specified range.
DeleteRowsDelete one or several rows from a specified position in a spreadsheet range. When you delete a row, the cells below are shifted up.
DeleteSheetDeletes the specified sheet from the specified spreadsheet.
Gets the list of named ranges within a spreadsheet.
Gets the list of named ranges and sheets within a spreadsheet.
Gets the list of sheets within a spreadsheet.
Retrieves a list of spreadsheets from the specified Google Drive location.
ReadCellReads the contents of the specified cell.
ReadRangeReads the contents of the specified range.
RenameSheetRenames the specified sheet in the specified spreadsheet.
WriteCellWrites information in the selected spreadsheet cell.
WriteColumnWrite a column in a selected Google Sheets file.
WriteRangeWrites a data table to the indicated range from the selected spreadsheet.
WriteRowWrite a row in a selected file using an Array or Data Row.

Examples

In the following example, you can see how you can use the APIs to get Google Sheets column values as array.
using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.GSuite.Sheets.Enums;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;
namespace GoogleWorkspaceCodedWorkflows
{
    public class GetGoogleSheetColumnAsArray : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {
             var GoogleSheetName= "Contacts";
             var service = google.Sheets(connections.GoogleSheets.<connectionID>);
             var columnArray = GetDataFromSheet(service,GoogleSheetName);
            foreach(string item in columnArray)
            {
                Log(item);
            }
        }
        public static IEnumerable<string> GetDataFromSheet(IGoogleSheetsService googleSheets, string name)
        {
            var sheets = googleSheets.GetSpreadsheets();
            var testDataSheet = sheets.FirstOrDefault(s => s.Name.StartsWith(name));
            var dt = testDataSheet.GetSheets().First().ReadRange(true);
            foreach (DataRow row in dt.Rows)
            {
                yield return row[1].ToString();
            }
        }
    }
}using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.GSuite.Sheets.Enums;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;
namespace GoogleWorkspaceCodedWorkflows
{
    public class GetGoogleSheetColumnAsArray : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {
             var GoogleSheetName= "Contacts";
             var service = google.Sheets(connections.GoogleSheets.<connectionID>);
             var columnArray = GetDataFromSheet(service,GoogleSheetName);
            foreach(string item in columnArray)
            {
                Log(item);
            }
        }
        public static IEnumerable<string> GetDataFromSheet(IGoogleSheetsService googleSheets, string name)
        {
            var sheets = googleSheets.GetSpreadsheets();
            var testDataSheet = sheets.FirstOrDefault(s => s.Name.StartsWith(name));
            var dt = testDataSheet.GetSheets().First().ReadRange(true);
            foreach (DataRow row in dt.Rows)
            {
                yield return row[1].ToString();
            }
        }
    }
}
  • Constructors
  • Methods
  • Examples

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.