简体   繁体   中英

Importing an Excel file to a SharePoint custom list programmatically UnauthorizedAccessException

I am trying to import the data from an Excel file into a SharePoint custom list programmatically using a Visual Studio Workflow coded in C#.

I am using the Microsoft.Office.Interop.Excel namespace and calling the Application() interface within it to provide a reference to the application so I can use it as suggested by many forums.

When I try this I receive an UnauthorizedAccessException error.

I have tried the RunWithElevatedPrivileges method from the SPSecurity class (as suggested here :)to try with system level privileges to no good effect. I should have system administrator privileges anyway since I am running this as a local development session on my laptop where the site is hosted locally.

If anyone has any ideas as to how I might get round this problem or can suggest an alternative method of importing the data from Excel to a SharePoint list it would be greatly appreciated.

I could do this same thing in MS Access in about 5 minutes. Right click import spreadsheet to linked sharepoint table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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