How do I embed excel in a form

Source: Internet
Author: User
Both. NET Framework1.0 and 1.1 do not implement Olecontainer components. Check MSDN, and finally got a hint: you can use Iebrowser to simulate olecontainer. This is definitely an overweight implementation, but, at the moment, it's the easiest way to do it. This article simply explains how to use the Iebrowser control to embed an Excel table.
1. First, you need to import the Microsoft WEB browser in the toolbar. You can right-click on the toolbar and select Add/Remove Items. Then select "COM Components" in the custom toolbox that appears, and finally find a "Microsoft Web browser" In the component, check and determine. See figure below:
2. Create a form, select the Microsoft Web browser component in the toolbar, and put it in the form.
3. Use the following code to import an Excel table:
Axwebbrowser1.navigate (@ "C:est Est.xls");
4. Join the AxWebBrowser1 DocumentComplete event. And get the OLE object for Excel in the event:
Public Excel.Workbook WB;
private void Axwebbrowser1_documentcomplete (object sender, Axshdocvw.dwebbrowserevents2_documentcompleteevent e)
{
WB = (excel.workbook) axwebbrowser1.document;
}
5. Through the WB, you can access the Excel table directly.
Although the use of IE control is very simple, but not a good way. There are currently only third-party controls, or expect. NET 2.0. If you have a better way, you might as well share it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.