===============高分求asp.net导出excel后 无法远程访问问题==========================

thbird thbird 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
问题是这样的: 在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();
#endregion

Response.Redirect(FilePath);
...全文
评论 10
收藏 已收藏
分享
返回顶部
thbird
.NET社区 62,273 成员 668,968 内容