首页 新闻 会员 周边 捐助

C#复制EXCEL 异常来自 HRESULT:0x800A03EC

0
悬赏园豆:20 [已关闭问题]

Excel.Application objExcel = null;
Excel._Workbook objBook = null;

objExcel = new Excel.Application();
objBook = objExcel.Workbooks.Open(@"D:\表样.xls", objMissing, objMissing, objMissing, objMissing, objMissing, objMissing, objMissing, objMissing, objMissing, objMissing, objMissing, objMissing, objMissing, objMissing);
Excel._Worksheet oldsheet = (Excel._Worksheet)objBook.Worksheets[1];


Excel.Application newExcel = new Excel.Application();
Excel.Workbook newbook = newExcel.Workbooks.Add(true);
Excel.Worksheet newsheet = newbook.Sheets[1] as Worksheet;
//设置禁止弹出保存和覆盖的询问提示框
newExcel.DisplayAlerts = false;
newExcel.AlertBeforeOverwriting = false;

oldsheet.Copy(objMissing, newsheet);        //这里出错    “ 异常来自 HRESULT:0x800A03EC”

newbook.Save();
newExcel.Save(@"c:\助学.xls");
newsheet = null;
newbook = null;
newExcel.Quit();
newExcel = null;


异常来自 HRESULT:0x800A03EC

这个就是想复制多个表的SHEET到新创建的EXCEL里,或都大家有什么好的方法可以实现要求带格式一起复制过去

烟仔的主页 烟仔 | 初学一级 | 园豆:155
提问于:2009-07-06 19:34
< >
分享
其他回答(3)
0
邀月 | 园豆:25475 (高人七级) | 2009-07-06 20:53
1

http://www.ureader.com/message/692318.aspx

winzheng | 园豆:8797 (大侠五级) | 2009-07-06 22:47
0

1.权限问题。可在控制面板----Administrative Tools----Component Services---Dcom config里面开放权限

2.你的office没有注册,或者没有激活。

West | 园豆:1095 (小虾三级) | 2009-07-07 09:56
0

楼主是怎样解决的,能否指教一下

奔跑*随心 | 园豆:140 (初学一级) | 2011-05-26 17:00
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册