简体   繁体   English

Excel Com Interop ASP.Net无法将文件写入磁盘。 权限?

[英]Excel Com Interop ASP.Net Cannot write file to disk. Permissions?

I've got a pretty simple web form which lets users pick reports, one specific report they want in xls with pretty formatting instead of CSV. 我有一个非常简单的Web表单,该表单可让用户选择报告,他们希望在xls中使用特定格式而不是CSV的特定报告。 I've whipped up the report using COM INTEROP with excel 2007. It works on my local machine and can write the file, but on the web server it fails with this error: 我在Excel 2007中使用COM INTEROP整理了报告。它在我的本地计算机上可以工作并且可以写入文件,但是在Web服务器上,它失败并出现以下错误:

Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space. Microsoft Office Excel无法打开或保存任何其他文档,因为没有足够的可用内存或磁盘空间。

• To make more memory available, close workbooks or programs you no longer need. •要提供更多的内存,请关闭不再需要的工作簿或程序。

• To free disk space, delete files you no longer need from the disk you are saving to. •要释放磁盘空间,请从要保存到的磁盘中删除不再需要的文件。

There is plenty of disk space on the server, so I don't think it's that - could this be a permissions issue? 服务器上有足够的磁盘空间,所以我认为不是-这可能是权限问题吗? I've escalated ASPNET and NETWORK SERVICE accounts to have write and modify access to the folder we're saving reports to - but still no joy. 我已经升级了ASPNET和NETWORK SERVICE帐户,以对我们要将报告保存到的文件夹进行写和修改访问权限-但仍然不愉快。 Any ideas? 有任何想法吗?

Do I need to invoke the com object with a specific user account, or maybe elevate the interop calls to administrator account? 我需要使用特定的用户帐户来调用com对象,还是需要将互操作调用提升为管理员帐户? Any idea how to do this? 任何想法如何做到这一点?

Sorry guys, sorted it. 抱歉,整理好了。

Serge you are halfway there. Serge,你在那儿。 I ended up running Excel as administrator: 我最终以管理员身份运行Excel:

in component services, select excel application and choose admin as the user that runs it. 在组件服务中,选择excel应用程序,然后选择admin作为运行它的用户。 Seems to work okay for the week of use it'll get :) 看起来可以正常使用一周了:)

Thanks all! 谢谢大家!

SpreadsheetGear for .NET will let you save xls and xlsx workbooks directly to a response stream with IWorkbook.SaveToStream. SpreadsheetGear for .NET允许您使用IWorkbook.SaveToStream将xls和xlsx工作簿直接保存到响应流中。 It is all safe managed C# code so there is no need to run anything as admin and you will not run into the problems that Excel COM Interop bring on an ASP.NET server. 都是安全的托管C#代码,因此无需以管理员身份运行任何程序,也不会遇到Excel COM Interop带来的ASP.NET服务器问题。

You can see some simple ASP.NET Excel Reporting samples (C# and VB) using SpreadsheetGear here and download the free trial here . 您可以看到使用的SpreadsheetGear一些简单的ASP.NET的Excel报表样本(C#和VB) 这里和下载免费试用这里

Disclaimer: I own SpreadsheetGear LLC 免责声明:我拥有SpreadsheetGear LLC

you might want to use impersonation for your ASPNET process; 您可能想在ASPNET进程中使用模拟功能; here's some info and example on how to do this: killing a win process from a C# console application: How do I set permissions? 以下是一些有关此操作的信息和示例: 从C#控制台应用程序终止Win进程:如何设置权限? more info on impersonation How to implement impersonation in an ASP.NET application 有关模拟的更多信息如何在ASP.NET应用程序中实现模拟

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

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