Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have Excel file stored in Microsoft One Drive. I want to read Excel Sheet Data using C# Console application. Is Possible to read Excel Sheet Data Stored in Microsoft One Drive.
I want to read Excel Sheet Data and get it in Json format.

What I have tried:

I have tried below code but it was Incomplete

private OneDriveFileList GetOneDriveRootListing()
{
var accessToken = GetAccessToken();
string jsonData;

string url = string.Format(@"https://apis.live.net/v5.0/me/skydrive?access_token={0}"
using (var client = new WebClient())
{
var result = client.OpenRead(new Uri(url));
var sr = new StreamReader(result);
jsonData = sr.ReadToEnd();
}

FileSystemBase driveInfo = JsonConvert.DeserializeObject<filesystembase>(jsonData);

url = string.Format("{0}?access_token{1}", driveInfo.Upload_Location, accessToken);
using (var client = new WebClient())
{
var result = client.OpenRead(new Uri(url));
var sr = new StreamReader(result);
jsonData = sr.ReadToEnd();
}

OneDriveFileList rootList = JsonConvert.DeserializeObject<onedrivefilelist>(jsonData);

return rootList;
}
Posted
Updated 16-Nov-18 1:51am
v3
Comments
Richard MacCutchan 16-Nov-18 4:27am    
"I have tried below code but it was Incomplete"
What exactly does that mean? If this is your own OneDrive then you can access it directly on your PC.
mechlin technology 16-Nov-18 5:40am    
Richard MacCutchan I want access OneDrive Excel file using code.

1 solution

You have to use the "Reply" link to reply to comments. What Richard was pointing out is, if this is your own OneDrive then you can access it directly.
"I have tried below code but it was Incomplete" does not to explain what the problem is with your code. I can't see anywhere where you are attempting to access an Excel spreadsheet.

But to answer your question
Quote:
Is Possible to read Excel Sheet Data Stored in Microsoft One Drive
Yes.
Here are some starters for your research:
access OneDrive with C#[^]
Excel Spreadsheet as JSON[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900