How to Automatically Download Excel File from SharePoint Every 20 Minutes in REFramework

I’m working on a UiPath project using the REFramework and I need help with integrating a routine that downloads an Excel file from SharePoint every 20 minutes.

Here are my constraints and setup:

  • I’m not using Azure or Office365/Graph API
  • The Excel file is stored in SharePoint (browser access only)
  • The file is used as the input source for transactions in REFramework
  • I want the bot to automatically download the latest file every 20 minutes
  • This should work on a local machine (no Orchestrator)

What’s the best practice to do this cleanly in the REFramework ? Appreciate any example, suggestions and your guidance.

Blockquote

@FS_Macalino

  1. If you want to do it clean then sharepoint ui is not a good idea
  2. But if you still need to then before download try to click on data so that the files gets reorganized as per date and you can click on the first file to download
  3. Coming to every 20 minutes..if no or hestratpr then mostly you are on attended license so there is no schedule possible you might need to run it from assistant
  4. One way still you have is use windows scheduler to schedule a bat file to run and in bat file use UiPath cli to run the process
  5. Again as no unattended the machine needs to be on and screen needs to be on for the automation to work as it uses ui

Cheers

1 Like

Hi @FS_Macalino , welcome to the community!

Is it a mandatory requirement to use UiPath to download the file?

Can you explain this a bit more? Are you not using Orch? Do you have an unattended bot lic? Have you tried UiPath Integration Service (assuming you have access) to access SharePoint?

Thank you Sudster!

Yes — I prefer to keep the whole process within UiPath if possible.
Here’s the background:

  • The Excel file contains user-submitted data from a portal.
  • Specifically, when a user submits a password reset request through the portal, the details (e.g., username, email, etc.) are stored in an Excel file hosted on SharePoint.
  • I want UiPath to automatically download this Excel file, and then use REFramework to process each row (transaction) and carry out the password reset actions.

So I’m thinking if UiPath alone can handle the download part

The most import question in my response was whether you have access to Orchestrator - Integration Service. Do you have an unattended bot lic?

Hi sudster,

We do not have an Orchestrator license at the moment.
We’re currently operating on an Attended Robot license only , and all processes are executed locally on a user’s machine.

From what I gathered, this is a perfect process for PowerShell - get a file, read contents, trigger active directory commands.

You can map SharePoint as a network drive, then it is up to you to use UiPath or just PS.

@FS_Macalino

Please go with the suggestions above..for attended they would work

Cheers

Hi @sudster @Anil_G

Thank you for your suggestions. I really appreciate the detailed guidance! :folded_hands:
I’m excited to try out the approaches you shared this coming work week. Will update the thread once I’ve tested everything. Thanks again!

1 Like

There is alternative way to achieve this by using c# you can create c# code to download file from SharePoint and create automatic trigger which will run in background and trigger every 20 minute.just build exe and run it background.
Below code for reference.

using Microsoft.SharePoint.Client;
using System;
using System.IO;
using System.Security;

class Program
{
static void Main()
{
string siteUrl = “https://yourtenant.sharepoint.com/sites/yoursite”;
string libraryTitle = “Documents”; // Name of your SharePoint document library
string fileName = “yourfile.xlsx”; // Name of the file to download
string downloadPath = @"C:\DownloadedFiles"; // Destination folder

    // Credentials
    string userName = "your_email@yourdomain.com";
    string password = "your_password";

    var securePassword = new SecureString();
    foreach (char c in password)
        securePassword.AppendChar(c);

    var ctx = new ClientContext(siteUrl)
    {
        Credentials = new SharePointOnlineCredentials(userName, securePassword)
    };

    // Path to the file inside the document library
    string fileUrl = $"/sites/yoursite/{libraryTitle}/{fileName}";

    // Download the file
    FileInformation fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(ctx, fileUrl);

    if (!Directory.Exists(downloadPath))
        Directory.CreateDirectory(downloadPath);

    using (var fileStream = System.IO.File.Create(Path.Combine(downloadPath, fileName)))
    {
        fileInfo.Stream.CopyTo(fileStream);
    }

    Console.WriteLine("Download complete!");
}

}

Trigger:

To create a time-based trigger in C# that executes at a specific time or every 20 minutes, there are two common and reliable approaches:

1. Using System.Timers.Timer for Fixed Intervals (e.g., Every 20 Minutes)

Example: Run a method every 20 minutes

csharp

using System;
using System.Timers;

class Program
{
    static void Main()
    {
        Timer timer = new Timer(20 * 60 * 1000); // 20 minutes in milliseconds
        timer.Elapsed += OnTimedEvent;
        timer.AutoReset = true;   // Continue recurring
        timer.Enabled = true;

        Console.WriteLine("Press any key to exit...");
        Console.ReadKey();
    }

    private static void OnTimedEvent(object sender, ElapsedEventArgs e)
    {
        Console.WriteLine("Triggered at: " + e.SignalTime);
        // Place your time-triggered code here
    }
}