Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
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.
Posted
Comments
Valery Possoz 19-Jan-13 6:01am    
Set you project as x86, not AnyCPu. That will force it to execute as a 32bit process even on 64b platforms.
adriancs 19-Jan-13 6:18am    
+1 Vote Up
V G S Naidu A 20-Jan-13 23:27pm    
thank you possoz, it's working with your technique. but i need to run the project as any cpu because it has the 64-bit dll's which support 64-bit operating system. if u please give me another suggestion.

1 solution

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.
 
Share this answer
 
v2
Comments
V G S Naidu A 20-Jan-13 23:26pm    
Hai Rob, thank you for your useful information.we have installed 64-bit office version in vista 64 bit Os,my application is running the project with the property "Any Cpu".In this case i could not open the office Excel(.xlsx) file embeded in winforms control(webbrowser control).it's working fine if i build the project as x86 type,but i could not make my Project as x86 type version because the project also running on 64-bit dll's, so i put it as any cpu. Here actually if i made my project as "Any CPU or x64" the .xlsx file opens as normal Excel file it's not loaded in webbroser control eventhough the 64-bit office installed.will please provide the another solution. Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900