Excel编程要求 [英] Requirement for Excel Programming

查看:80
本文介绍了Excel编程要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我正在Excel工作簿(Xlsx)上执行阅读操作
我的计算机上未安装Msoffice,
在创建ExcelWorkBook的对象时,它会抛出类似
的错误
由于以下错误,检索具有CLSID {00024500-0000-0000-C000-000000000046}的组件的COM类工厂失败:80040154未注册类(HRESULT的异常:0x80040154(REGDB_E_CLASSNOTREG)).

因此,我的问题是要在Excel上执行编程,是否需要先安装MsOffice excel?

Hello,
I am Performing Reading operation on Excel Workbook (Xlsx)
I do not have Msoffice installed on my Machine,
While Creating Object of ExcelWorkBook it throws error Like

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

So My Question is that to Perform Programming on Excel is there a need to install MsOffice excel first ?

推荐答案

是的,您必须安装MSOffice.
您也可以为此使用OLEDB Provider.

这是您的代码-
Yes, you have to install MSOffice.
You can also use OLEDB Provider for this.

This is code for u -
string connectionString = String.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1;""", fileName);
string query = String.Format("select * from [{0}


", Sheet1"); OleDbDataAdapter dataAdapter = OleDbDataAdapter(query,connectionString); DataSet ds = DataSet(); dataAdapter.Fill(ds); 返回 ds;
", "Sheet1"); OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connectionString); DataSet ds = new DataSet(); dataAdapter.Fill(ds); return ds;


MS Office不仅为您提供Excel,Word等,而且还提供了允许数据操作,导入导出,VBA等.

必须安装它才能使iis等具有可用功能.
MS Office does not just give you Excel, Word etc, but also the framework that allows data manipulation, import export, VBA etc.

It is necessary for it to be installed in order to have the functionality available for iis etc.


这篇关于Excel编程要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆