Neither. NET Framework1.0 nor 1.1 implements the OleContainer component. Check MSDN and get a prompt: You can use IEBrowser to simulate OleContainer. This is definitely an overweight implementation. However, it is the most time-consuming method. This article briefly describes how to use the IEBrowser control to embed an Excel table.
1. First, import "Microsoft WEB Browser" in the toolbar ". You can right-click the toolbar and select "Add/Remove items ". Select "COM component" in the Custom toolbox that appears, find "Microsoft Web Browser" in the component, select and confirm. See:
2. Create a Form, select the "Microsoft Web Browser" component in the toolbar, and place it in the Form.
3. Use the following code to import an Excel file:
AxWebBrowser1.Navigate (@ "c: estest.xls ");
4. Add the DocumentComplete event of axwebbrowser1. And obtain the Excel Ole object in the event:
Public Excel. Workbook wb;
Private void axWebBrowser1_DocumentComplete (object sender, AxSHDocVw. DWebBrowserEvents2_DocumentCompleteEvent e)
{
Wb = (Excel. Workbook) axWebBrowser1.Document;
}
5. Using wb, you can directly access the Excel table.
Although it is easy to use the IE control, it is not a good method. Currently, only third-party controls are available, or. NET 2.0 is expected. If you have a better method, share it.