如何使用C#在嵌入的Winforms控件中打开Excel文档(.xlsx) [英] how to open the Excel document(.xlsx) in embeded Winforms Control Using C#

查看:138
本文介绍了如何使用C#在嵌入的Winforms控件中打开Excel文档(.xlsx)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai,



我正在尝试使用webbrowser Control在Windows窗体中显示Excel文档。



使用在Codeproject中搜索的代码如何整合使用WebBrowser的Windows窗体应用程序中的Excel [ ^ ]我能够在webbrowser控件中正确地将32位操作系统中的文件(.xls和.xlsx)显示出来。



但是当我试图在64位操作系统中执行代码.xlsx类型的Excel文件没有在webbrowser控件中打开而是打开它们作为正常的excel文件但是.xls文件打开正确地在webbrowser控件中。

为此我执行了注册脚本以使用以下链接更改注册表设置http://support.microsoft.com/kb/927009 [ ^ ]

但.xlsx文件总是像Office excel文件一样单独打开,而不是在webbrowser控件中打开它。



目前我使用Microsoft Office 2010软件作为我的办公工具。



请提供打开.xlsx文件的解决方案在webbrowser控件中打开。



谢谢。

Hai,

I am trying to display the Excel document in windows forms using the webbrowser Control.

using the code googled in Codeproject How to Integrate Excel in a Windows Form Application using the WebBrowser[^] and i am able to disaply excel(.xls and .xlsx) files in 32 bit Operating System correctly in webbrowser control.

But when i trying to execute the code in 64-bit operating system .xlsx type Excel files didn''t open in webbrowser Control instead they were opening as normal excel file but .xls files opening correctly in webbrowser Control.
For that i executed the register Script to change the registry settings using the below link http://support.microsoft.com/kb/927009[^]
but .xlsx files always Open separately as like Office excel file instead of opening it in webbrowser Controls.

Presently i am using Microsoft Office 2010 software as my office tool.

Please provide the solution to open the .xlsx files to be open in webbrowser control.

Thank you.

推荐答案

如果您安装了32位办公室在64位操作系统中,您必须将winforms应用程序编译为x86而不是AnyCPU。如果它被编译为AnyCPU,它将启动64位CLR,它不能托管32位办公室互操作dll。



旧的xls格式由Jet引擎支持对于64位和32位并排支持,新的xlsx格式由更新的引擎支持,该引擎具有并排支持。这是一个主要的痛苦,但有关64位支持的信息直接来自Microsoft支持 - 他们更长时间打算提供并排支持,因为将文件支持视为办公室的一部分,而不是操作系统的一部分。幸运的是,很少有人安装64位办公室,即使在64位操作系统上,因此编译x86将在任一操作系统上使用32位办公室。如果您必须同时支持32位办公室和64位办公室,则需要两个版本(一个AnyCPU或x64和一个x86),并且需要确定您在安装时与哪个办公室版本进行交互。
If you have 32 bit office installed in a 64 bit OS, you must compile your winforms application as "x86" not "AnyCPU". If it is compiled as "AnyCPU" it will start the 64 bit CLR which cannot host 32 bit office interop dlls.

The older xls format was supported by the Jet engine, which has side by side support for both 64 and 32 bit, the newer xlsx format is supported by a newer engine that does have side by side support. This is a major pain in the neck, but the information about 64 bit support was directly from Microsoft support - they nmo longer intend to provide side by side support, as the see the file support as part of office, not part of the OS. Fortunately, few people install 64 bit office, even on a 64 bit OS, so compiling for x86 will work with 32 bit office on either OS. If you have to support both 32 bit office, and 64 bit office, you will need two versions (one AnyCPU or x64 and one x86), and will need to determine which office version you are interacting with at install time.


这篇关于如何使用C#在嵌入的Winforms控件中打开Excel文档(.xlsx)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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