C # embedded excel, winform embedded ecxel,. Net embedded excel, winform open excel, webbrowser open Excel)

Source: Internet
Author: User

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;

}

 

 

Related Article

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.