c# - Strange error on Excel Workbook input -


for current code:

 string currentpath = directory.getcurrentdirectory();          openfiledialog op = new openfiledialog();         op.initialdirectory = currentpath;         if (op.showdialog() == dialogresult.ok)             currentpath = op.filename;         else         {             toolstripstatuslabel1.text = "failed load workbook";             toolstripstatuslabel1.visible = true;         }          workbook wb = new workbook(excel.workbooks.open(currentpath)); 

i recieve error:

system.runtime.interopservices.comexception unhandled message=retrieving com class factory component clsid {00020819-0000-0000-c000-000000000046} failed due following error: 80040154 class not registered (exception hresult: 0x80040154 (regdb_e_classnotreg)). source=mscorlib errorcode=-2147221164

all want predefined workbook add worksheets to

i suppose in code fullname of workbook microsoft.office.interop.excel.workbook, , excel instance of microsoft.office.interop.excel.application.

if case code can't work because workbook interface, , interfaces not have constructors. have ask excel application create workbooks you, , in case have write:

workbook wb = excel.workbooks.open(currentpath);  

in similar way, if want create new empty workbook, should write:

workbook wb = excel.workbooks.add(system.reflection.missing.value); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -