From: http://www.cnblogs.com/ok519/archive/2009/09/21/1570903.html
Recently, the winform application was developed, involving the embedding of Excel files. Technical verification is also coming to an end. You need to sort out the help documentation ..
Open excel with the webbrowser control.
/// <Summary>
///
/// </Summary>
Public static Microsoft. Office. InterOP. Excel. range = NULL;
/// <Summary>
///
/// </Summary>
Public static Microsoft. Office. InterOP. Excel. Workbook WBB = NULL;
/// <Summary>
/// Open an Excel file
/// </Summary>
/// <Param name = "filepath"> Excel file path </param>
Public void openexcel (string filepath)
{
Strfilepathandfilename = filepath;
// Object refmissing = system. reflection. Missing. value;
This. webbrowser1.navigate (strfilepathandfilename );
// Object axwebbrowser = This. webbrowser1.activexinstance;
}
Private void webbrowserappsdocumentcompleted (Object sender, webbrowserdocumentcompletedeventargs E)
{
Object refmissing = system. reflection. Missing. value;
Object [] ARGs = new object [4];
ARGs [0] = shdocvw. olew.id. olecmdid_hid1_lbars;
ARGs [1] = shdocvw. olecmdexecopt. olecmdexecopt_dontpromptuser;
ARGs [2] = refmissing;
ARGs [3] = refmissing;
Object axwebbrowser = This. webbrowser1.activexinstance;
Axwebbrowser. GetType (). invokemember ("execwb", bindingflags. invokemethod, null, axwebbrowser, argS );
Object oapplication = axwebbrowser. GetType (). invokemember ("document", bindingflags. getproperty, null, axwebbrowser, null );
WBB = (Microsoft. Office. InterOP. Excel. workbook) oapplication;
}