Not able to read an excel from SharePoint using C#

Copper Contributor

Hello,

 
We have a requirement to read excel files (xlsx, xls and csv) from SharePoint into the memory by using C# code and perform some operations.
To achieve this requirement, we have used "Microsoft.Office.Interop.Excel" assembly and written below code that we have found doing google.
 
 
 
Code.PNG

 

Here, I am not sure whether this code is working or not, because after executing this code, I have been asked to enter user name and password into the new window. After providing a username and password, an error is occurring in user name and password screen. Please see below screen

 

Error.png

 

There are two questions I have.
1. How do I provide username and password in a code itself, so that this will not prompt to enter?
2. Why is this type of error coming when I enter a username and password?
 
Any help would be much appreciated.
 
OR any one also suggests if I can use any other way to read excel files directly from SharePoint.

 

0 Replies