问题是这样的: 在asp.net中,把dataTable中的数据导入到excel. 目前本地已经测试没有问题,但局域网中的其它机子访问导出后的excel文件时,没有任何反映.     我已经设置了文件目录everyone读写权限. 以及在Dcom配置中的excel应用程序的"启动和激活权限" "访问权限" 给于了everyone所有的权限.代码如下:Excel.ApplicationClass myApp;        
Excel.Workbook myBook; 
Excel.Worksheet mySheet; 
string tableName = "mp_ZZFY";
string FilePath = Server.MapPath(tableName); //模板文件路径myApp = null; 
myBook = null; 
mySheet = null; object oMissiong = System.Reflection.Missing.Value; myApp = new Excel.ApplicationClass(); myApp.Visible = false;                       myApp.Workbooks.Open(FilePath, oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong); myBook=myApp.Workbooks[1]; mySheet=(Excel.Worksheet)myBook.ActiveSheet; #region 一个萝卜一个坑
mySheet.Cells[i,j] = DataTable中的数据;
.......
#endregion
myBook.Save();myBook.Close(true,FilePath,true); //myApp.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(mySheet); System.Runtime.InteropServices.Marshal.ReleaseComObject(myBook); System.Runtime.InteropServices.Marshal.ReleaseComObject(myApp); GC.Collect(); 
#endregionResponse.Redirect(FilePath);

解决方案 »

  1.   

    这个其实就是下载一个Excel文件到客户端,跟权限没有关系吧?建议检查一下客户端,看是不是安装了什么流氓的IE插件原因导致的回复了两次~~
      

  2.   

    1,可以启用模拟,模拟一个管理员权限的用户进行测试
    http://support.microsoft.com/?id=306158
    2,两个excel版本相同么?不同的版本参数不同
    3,不建议在服务器端使用office应用程序
    http://support.microsoft.com/kb/288367/zh-cn4,由于excel与html的兼容性,你只需要生成扩展名字为.xls的文本文件即可.这样简单方便少出错
      

  3.   

    直接new个DataGrid之类的然后Render出来存成后缀名xls就行了,还在服务器端用什么office啊晕office遇到意外情况的默认做法是和用户交互,iis里调用可就惨了找神仙交互去
      

  4.   

    谢谢大家的回复.
    Re syeerzy: 因为我的xls格式是固定的.需要把datatable中的数据以固定的位置填进去.re net_lover: 我用http://localhost/...可以.  但在本机用ip访问就不行.比如http://192.168.0.169/...(通过ip访问,其它功能没问题.只有读取excel文件有问题),所以不存在excel版本问题.
      

  5.   

    楼主,我遇到了跟你一样的问题。
    问题应该出在FilePath上。string FilePath= Server.MapPath(tableName)是本地路径。Response.Redirect(FilePath) 转向的依然是本地的这个路径。在本机是没有问题的。但在客户端就不行。应该改成网络路径,如 Http://你的机器名/../文件名  你可以试试。我的就是这种状况。