从HRESULT获取异常:在excel工作簿中添加新工作表时为0x800A03EC

时间:2014-05-20 12:42:33

标签: c# asp.net excel

在excel工作簿中添加新工作表时,我从HRESULT获取异常:0x800A03EC:

 Microsoft.Office.Interop.Excel._Workbook m_objBook = null;
 object m_objOpt = "Test";
   m_objBook = (Microsoft.Office.Interop.Excel._Workbook)(m_objBooks.Add(m_objOpt));
   m_objSheets = (Microsoft.Office.Interop.Excel.Sheets)m_objBook.Worksheets;
   m_objSheet1 = (Microsoft.Office.Interop.Excel._Worksheet)(m_objSheets.get_Item(1));
   m_objSheet1.Name = "Project List";
   m_objSheet2 = (Microsoft.Office.Interop.Excel._Worksheet)(m_objSheets.get_Item(2))
   m_objSheet2.Name = "Project Status";
   m_objSheet3 = (Microsoft.Office.Interop.Excel._Worksheet)(m_objSheets.get_Item(3));
   m_objSheet3.Name = "Pending items";

在下面一行我收到错误 - 来自HRESULT的异常:0x800A03EC

   m_objSheet4 = (Microsoft.Office.Interop.Excel._Worksheet)(m_objSheets.Add  (m_objOpt, m_objSheet3, 1, m_objOpt));

   m_objSheet4 = (Microsoft.Office.Interop.Excel._Worksheet)(m_objSheets.get_Item(4));
   m_objSheet4.Name = "NewSheet";

0 个答案:

没有答案