简体   繁体   English

使用C#和ASP.NET MVC在OneDrive上读取Excel(xlsx)文件

[英]Read an Excel (xlsx) file on OneDrive using C# & ASP.NET MVC

I have a OneDrive shared link for an excel file with some data. 我有一个带有一些数据的excel文件的OneDrive共享链接。 And I need to read this excel file through my C# ASP.NET MVC web application without downloading it to local PC. 而且我需要通过C#ASP.NET MVC Web应用程序读取此excel文件,而无需将其下载到本地PC。 But I'm new to this 'OneDrive API'. 但是我是这个“ OneDrive API”的新手。 So I have a serious challenge with this. 因此,我对此提出了严峻的挑战。 I'm familiar with local file read as in, 我熟悉读取的本地文件,

EX: EX:

var package = new ExcelPackage(new System.IO.FileInfo(PATH));

I'd really appreciate if anyone can guide me or provide a sample code to do this. 如果有人可以指导我或提供示例代码来帮助我,我将非常感谢。 I just need to access the ExcelPackage of the .xlsx file. 我只需要访问.xlsx文件的ExcelPackage Thank you in advance. 先感谢您。

PS : I have tried some options like 'WebRequest', 'Webclient', etc. :( PS:我已经尝试了一些选项,例如“ WebRequest”,“ Webclient”等:(

You could try something like HttpClient.GetStreamAsync to open a download stream for the remote file and then pass the returned Stream to the ExcelPackage constructor (documentation states it has a constructor that accepts an instance of a Stream ). 您可以尝试使用诸如HttpClient.GetStreamAsync之类的方法来打开远程文件的下载流,然后将返回的Stream传递给ExcelPackage构造函数(文档指出它具有一个接受Stream实例的构造函数)。

Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM