Microsoft.Office.Interop上的{&Exception from HRESULT:0x800A03EC"} [英] {"Exception from HRESULT: 0x800A03EC"} at Microsoft.Office.Interop
本文介绍了Microsoft.Office.Interop上的{&Exception from HRESULT:0x800A03EC"}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用ASP.Net web applcation中的以下代码创建一个excel文件。
当我从visual studio运行时,代码正常工作,但是工作簿出现异常。我在IIS上部署应用程序并运行部署版本时关闭命令。
I am trying to create an excel file using the below code in an ASP.Net web applcation.
The code works normally when I run from visual studio, but an exception occur workbook.Close command when I deploy the application on IIS and run the deployed version.
Excel.Application exc = null;
try
{
exc = new Excel.Application();
Excel.Workbooks workbooks = exc.Workbooks;
Excel._Workbook workbook = workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
Excel._Worksheet worksheet = (Excel._Worksheet)workbook.Worksheets[1];
Excel.Range range = worksheet.get_Range("A1", System.Reflection.Missing.Value);
Object[] data = new Object[] { "" };
range.GetType().InvokeMember("Value", System.Reflection.BindingFlags.SetProperty, null, range, data);
workbook.Close(true, p_sTempFileName, null);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\n" + ex.InnerException);
Console.ReadLine();
}
finally
{
if (exc != null)
exc.Quit();
}
推荐答案
检查此链接: http://www.c-sharpcorner.com/UploadFile/jayendra/5443/
检查HRESULT异常:0x800A03EC的部分
check the section where it says "Exception from HRESULT: 0x800A03EC"
希望它有效。
这篇关于Microsoft.Office.Interop上的{&Exception from HRESULT:0x800A03EC"}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文