We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Opening xlsx doc from Onedrive

Hi, I have seen an article on your site about using xlsio to interact with files stored on onedrive, but it was specifically for uwp apps. Is this concept also possible from a winform app? Do you have a sample of this?

What methods could be used, graph api, etc?

Any insight will be much appreciated!

20 Replies

KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team January 22, 2020 12:53 PM UTC

Hi Travis, 

Greetings from Syncfusion. 

We are preparing sample in Windows Forms application and we will share the sample on 24th January 2020. 

Regards, 
Keerthi. 



KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team January 24, 2020 09:49 AM UTC

Hi Travis, 

Thanks for your patience. 

We have prepared the sample in Windows Forms application to edit and save Excel file in OneDrive using Microsoft Graph. The sample can be downloaded from the following link. 


Kindly add your Application ID under appSettings tag in App.Config file, before executing the sample. 

Regards, 
Keerthi. 



TC Travis Chambers January 25, 2020 04:58 AM UTC

Thank you very much. This works great! I do have one question though that I hope might can help with. 

Every time the api is called to open the xlsx doc from OneDrive it prompts the auth login screen. Is it possible to do this with a single sign on.

My application requires opening and saving the document multiple times during a single session, so only authenticating once would be idea. Any knowledge you can share would be great.

Thanks!


KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team January 27, 2020 12:53 PM UTC

Hi Travis, 

Thanks for the update.  

We are glad that the provided sample helped you. We are checking the feasibility for single sign-in and will share the details on 28th January 2020. 

Regards, 
Keerthi. 



TC Travis Chambers January 27, 2020 03:21 PM UTC

Thank you very much. I have actually figured it out. I added an if clause in the GetTokenAsync method checking to see if an account is logged into (using GetAccountsAsyc), and if so, it calls AcquireTokenSilentAsyc which works great.

I do have a fairly related question though in regards to using the graph API. XlSIO having compatibility with the API is awesome! Is there also compatibility between the treeViewAdv and Graph? 

I currently load a network drive (such as C: drive) into that control using FileInfo. Is it possible to load the control with a OneDrive directory?

Thanks!


KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team January 28, 2020 12:33 PM UTC

Hi Travis, 

Thanks for the update. 

Please find the response for the queries below. 

Query 
Response 
Thank you very much. I have actually figured it out. I added an if clause in the GetTokenAsync method checking to see if an account is logged into (using GetAccountsAsyc), and if so, it calls AcquireTokenSilentAsyc which works great. 
We are glad that you if could achieve your requirement. 
I do have a fairly related question though in regards to using the graph API. XlSIO having compatibility with the API is awesome! Is there also compatibility between the treeViewAdv and Graph?  
 
I currently load a network drive (such as C: drive) into that control using FileInfo. Is it possible to load the control with a OneDrive directory? 

Could you please let us know whether the requirement is to load the contents of Excel file downloaded from the One Drive as nodes in the TreeViewAdv and then after performing some modifications in the nodes in TreeViewAdv, you want to load the modified TreeViewAdv as Excel file and upload back to One Drive. 

Also please let us know incase if we have misunderstood the query in TreeViewAdv as it will help us to further proceed on this. 

Regards, 
Keerthi.


TC Travis Chambers January 28, 2020 04:36 PM UTC

Hi, I'm not dealing with excel documents in the tree view.

Currently, the tree view list files folders from a local drive (such as c: drive). When a node is clicked all documents in that folder are displayed in a datagridview.

So, I would like to treat OneDrive like a local drive and list all folders and subfolders from one drive in the tree view and all documents in the datagridview when a folder is selected.

Essentially it is like FileExplorer, but being fed from onedrive instead of a local drive.

Thanks!


GS Gokul Sainarayanan Syncfusion Team January 29, 2020 04:52 PM UTC

Hi Travis,

Thanks for your update.

We have checked your reported query and we understand that your requirement is to perform LoadOnDemand in TreeViewAdv. We have a LoadOnDemand sample in which we have loaded the directories and folders from the machine as nodes in TreeViewAdv. Please find the sample in the following location and let us know whether it helps to achieve your requirement where you need to perform LoadOnDemand from the OneDrive.

Sample: https://www.syncfusion.com/downloads/support/forum/150848/ze/TreeViewAdv_LoadOnDemand-2061933052  

Regards,
Gokul S


TC Travis Chambers January 30, 2020 04:28 AM UTC

Thanks for your response. This is not quite what I'm looking for though. I am already loading my local network drives into the treeview. What I was hoping to do is load the onedrive drives using the graph api, if that is possible.

Thanks!


GS Gokul Sainarayanan Syncfusion Team January 31, 2020 01:31 PM UTC

Hi Travis,

Thanks for your update.

We will check with the Microsoft Graph API to load the OneDrive contents into the TreeViewAdv and will let you know on or before February 4, 2020. We appreciate your patience until then.

Regards,
Gokul S


GS Gokul Sainarayanan Syncfusion Team February 4, 2020 04:36 PM UTC

Hi Travis,

Sorry for the inconvenience caused.

As we faced some delay in getting the permission from accessing the OneDrive for registering the application in the portal, we are unable to update the compatibility of loading the contents into TreeViewAdv today as promised before. We are currently working on this with high priority and will provide the complete details on February 5, 2020. We appreciate your patience until then.

Regards,
Gokul S


GS Gokul Sainarayanan Syncfusion Team February 5, 2020 04:30 PM UTC

Hi Travis,

Sorry for the inconvenience caused.

We are still facing the issues in accessing the OneDrive content through MicrosoftGraph as it needs organization admin approval for accessing it. We have directed to the corresponding team for their approval and once we get the approval for the same, we will check the reported query in TreeViewAdv and provide you further details on February 7, 2020.

Meanwhile we are also checking ways to retrieve the details of files and folders and its content in order to load them in TreeViewAdv. Also if possible, let us know incase if you come across any of the ways to retrieve the details.

Regards,
Gokul S


TC Travis Chambers February 5, 2020 05:01 PM UTC

Thank you for working so diligently. Your help is greatly appreciated!


GS Gokul Sainarayanan Syncfusion Team February 6, 2020 02:22 PM UTC

Hi Travis,

Thanks for your update.

We are still waiting for the organization level administrator approval from the corresponding team. We will provide you further details on February 7, 2020. We appreciate your patience until them.

Regards,
Gokul S


GS Gokul Sainarayanan Syncfusion Team February 7, 2020 04:53 PM UTC

Hi Travis,

Thank you for your patience.  
 
We have checked the reported query to retrieve the contents from the OneDrive. Based on our understanding of your reported query, the below main folders in the OneDrive are needed to be added as root nodes in the TreeViewAdv. We can access the folders and files using the below code snippet.

Screenshot:



Code snippet:
 
 
 
var stream1 = await graphClient.Me.Drive.Root.Children.Request().GetAsync(); 
 

  
Now the stream1 à CurrentPage contains all the items present here(Attachments, Microsoft Teams Chat Files and Notebooks as in the above case). The items present here can be differentiated as File when stream1.CurrentPage[0].Folder is Null whereas the item is a Folder when stream1.CurrentPage[0].File is Null. The Name(steam1.CurrentPage[0].Name) of these folders can be set as TreeNodeAdv’s Text in the TreeViewAdv.

We can check whether the folder has subitems using stream1.CurrentPage[0].Children count. If there any subitems then they can be accessed by passing the name of the parent folder using the below code snippet. Then similar to explained above, we can add child nodes to the parent node.

Code snippet: 
 
var stream2 = await graphClient.Me.Drive.Root.ItemWithPath("Notebooks").Children.Request().GetAsync(); 
 

As we are still some delay in getting the admin approval, we are unable to prepare a sample for it. However on checking and analyzing through other means, we were able to identify the ways to access the folders and files. Please check and let us know whether the above code snippets help your reported query.

Regards,
Gokul S 



TC Travis Chambers February 20, 2020 01:53 AM UTC

Thank you for your help on this! After some experimentation I sort of have it working. I am able to load the treeview with the folders with only a few occasional instances of odd behavior, which I can deal with. 

I have struggled, however, to manage the documents within each folder. What I am trying to do is load a separate control gridcontrol) with a list of document names belonging to the selected folder (loading on multicolumntreeview_click), but that is proving to be difficult, mostly because of threading issues as graph apparently uses multiple threads.

I am ultimately trying to mimic FikeExplorer but with OneDrive docs.

Regardless, this is a good start and I greatly appreciate your help!


ON Olety Nikhilesh Olety Nagendra Syncfusion Team February 20, 2020 02:26 PM UTC

Hi Travis,

Thank you for the update

We are analyzing the reported behavior with populating the items to GridControl. We will analyze this and will  provide you further details in two business days ( February 24, 2020).

We appreciate your patience until then.

Regards,
Nikhilesh O



ON Olety Nikhilesh Olety Nagendra Syncfusion Team February 24, 2020 09:31 AM UTC

Hi Travis,

Thank you for your patience.

We have prepared a simple sample with loading the list of folders under the selected node and then bind the folders into a GridControl, please find the sample below where we have binded the folders available from system local storage.


Please refer the sample and you can the same binding for loading the folders from the TreeView to GridControl.

Regards,
Nikhilesh O



TC Travis Chambers February 25, 2020 03:29 AM UTC

Thank you for your feedback, but this is not what I am looking for. I am already able to load folders and docs from local drives easily. I want to now treat OneDrive the same way, loading folders into a multi-column tree view and documents into a gridcontrol (when a folder is selected).

The DriveInfo class doesn't apply to OneDrive files unfortunately. I am trying to do this using the Microsoft Graph API.

Thanks.


ON Olety Nikhilesh Olety Nagendra Syncfusion Team February 25, 2020 12:00 PM UTC

Hi Travis,

Thank you for the update.

You can refer the below link which is a OneDriveAPIBrowser sample that uses the Microsoft Graph .NET Client Library for C#/.NET. You can use this as a reference for accessing from one drive. 


Please let us know if this is helpful on your side.

Regards,
Nikhilesh O


Loader.
Up arrow icon