如何在不同的凭据中打开Excel工作表? [英] How can I open an excel sheet in different credential?

查看:149
本文介绍了如何在不同的凭据中打开Excel工作表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用StartInfo打开Excel工作表不起作用。



我尝试过:



我尝试使用模拟类进行模拟,但它无法正常工作。然后我使用Process.StartInfo.UserName和Process.StartInfo.Password传递了我的用户凭证,它无法正常工作。我正在使用不同的用户凭证打开CMD提示,然后我使用命令/ C start excel'\\ mynetwork\filename.xls'

解决方案

您模拟的用户必须拥有您尝试打开文件的网络共享的权限。



此外,UNC路径 \\servername\sharename\folderpath\filename


Process.StartInfo.LoadUserProfile设置为true,它可以解决问题。

Opening an excel sheet using StartInfo is not working.

What I have tried:

I tried impersonating using the impersonation class, it is not working. Then I passed my user credential using Process.StartInfo.UserName and Process.StartInfo.Password, it is not working. I am opening a CMD prompt with a different user credential, then I am using the command "/C start excel '\\mynetwork\filename.xls'"

解决方案

The user you impersonate has to have permissions to the network share you're trying to open the file from.

Also, a UNC path is \\servername\sharename\folderpath\filename


Process.StartInfo.LoadUserProfile is set to true and it does the trick.


这篇关于如何在不同的凭据中打开Excel工作表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆