用sl导出excel,打开模板的时候我是这样写的dynamic excel = AutomationFactory.CreateObject("Excel.Application");
excel = File.OpenWrite("/Template/课题项目到款汇总.xls");提示错误:
{System.Security.SecurityException: 不允许进行文件操作。拒绝访问路径“/Template/课题项目到款汇总.xls”。
位于 System.IO.FileSecurityState.EnsureState()
位于 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
位于 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
位于 System.IO.File.OpenWrite(String path)
位于 CNZH.SL.Common.ExportExcel.ExportToExcel(String FileName, List`1 DataList, String[] parms)
位于 CNZH.SL.Views.ProduceProjectSummary.button1_Click(Object sender, RoutedEventArgs e)
位于 System.Windows.Controls.Primitives.ButtonBase.OnClick()
位于 System.Windows.Controls.Button.OnClick()
位于 System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
位于 System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
位于 MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)}
请问如何解决?还是我写的不对?请大虾们指教,注意,是OOB,不是web
excel = File.OpenWrite("/Template/课题项目到款汇总.xls");提示错误:
{System.Security.SecurityException: 不允许进行文件操作。拒绝访问路径“/Template/课题项目到款汇总.xls”。
位于 System.IO.FileSecurityState.EnsureState()
位于 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
位于 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
位于 System.IO.File.OpenWrite(String path)
位于 CNZH.SL.Common.ExportExcel.ExportToExcel(String FileName, List`1 DataList, String[] parms)
位于 CNZH.SL.Views.ProduceProjectSummary.button1_Click(Object sender, RoutedEventArgs e)
位于 System.Windows.Controls.Primitives.ButtonBase.OnClick()
位于 System.Windows.Controls.Button.OnClick()
位于 System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
位于 System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
位于 MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)}
请问如何解决?还是我写的不对?请大虾们指教,注意,是OOB,不是web
解决方案 »
- 未将对象引用设置到对象的实例。
- 文件上传后扫描下是否病毒
- 一个简单的页面传值问题,但查过很多网页没有解答,请高手相助呀--急!!!!!!!
- 提問:TREEVIEW調用動態數據最多可以展開多少個層?
- asp.net 一般如何处理页面间变量的传递
- 在asp.net中,如何从数据库得到一列数据,然后用滚动字幕显示,滚动字幕要带链接。
- ASPxGridView 的GridViewDataComboBoxColumn 取值问题!
- 高手请来,DataGrid中的验证问题:
- 为什么几种url都能打开网址 这样对SEO有没有影响?如何避免?
- 制作发邮件程序出错,高手请教!
- 收邮件 jmail 出现错误 帮我看一下
- vs2010里面如何让JavaScript脚本能够匹配括号【☆】
http://msdn.microsoft.com/zh-cn/library/ee721083(VS.95).aspx如果想要访问文件系统,可以通过 AutomationFactory.CreateObject("Scripting.FileSystem") 去实现,参考 jv9 的代码:
http://topic.csdn.net/u/20100729/09/b7ef8071-6ba8-43ee-80a6-0d3c6d0aedea.html