If you're not sure how to put dspframer.ocx on a form, look at an article detailing how it's placed on a form.
Links: http://www.cnblogs.com/pingming/p/4182045.html
First step to create a new form
Create a new form, place a panel container control, and we're going to put dsoframer.ocx inside the panel.
The second step below is all the methods that are called, with steps.
Public Partial classExcelForm:DevExpress.XtraEditors.XtraForm {PrivateAxdsoframer.axframercontrol M_axframercontrol =NewAxdsoframer.axframercontrol (); PublicExcelform () {InitializeComponent (); } #regionLoad of Excel//The total load Excel method Private voidInit (string_excelfilepath) { Try{Regcontrol (); if(!file.exists (_excelfilepath)) {Xtramessagebox.show ("File formats that do not exist or are not identified! ","Prompt Information"); return; //throw new ApplicationException ("The file does not exist or the file format is not identified!") ");} addaxframercontrol ();//loading a Fill controlInitofficecontrol (_excelfilepath); } Catch(Exception ex) {Throwex; } }//Step Two: Populate the panel with the Axframercontrol control Private voidAddaxframercontrol () {Try { This. PANELEXCEL.CONTROLS.ADD (M_axframercontrol); M_axframercontrol.dock=DockStyle.Fill; } Catch(Exception ex) {Xtramessagebox.show (ex). Message); Throw; } } //First step: Register Axframercontrol Public BOOLRegcontrol () {Try{Assembly Thisexe=assembly.getexecutingassembly (); System.IO.Stream MyS= Thisexe.getmanifestresourcestream ("NameSpaceName.dsoframer.ocx"); stringspath = System.AppDomain.CurrentDomain.BaseDirectory +@"\dsoframer.ocx"; ProcessStartInfo PSI=NewProcessStartInfo ("regsvr32","/ S"+spath); Process.Start (PSI); } Catch(Exception ex) {MessageBox.Show (ex). Message); } return true; } //The following method is a parameter that the DSO needs when opening a file, representing the Office file type /// <summary> ///Open by suffix name/// </summary> /// <param name= "_sexten" ></param> /// <returns></returns> Private stringLoadopenfiletype (string_sexten) { Try { stringSopentype =""; Switch(_sexten.tolower ()) { Case "xls": Sopentype="Excel.Sheet"; Break; Case "Doc": Sopentype="Word.Document"; Break; Case "ppt": Sopentype="Powerpoint.show"; Break; Case "VSD": Sopentype="visio.drawing"; Break; default: Sopentype="Word.Document"; Break; } returnSopentype; } Catch(Exception ex) {Throwex; } } /// <summary> ///Step Three: Initialize the Office control, load Excel/// </summary> /// <param name= "_sfilepath" >Local Document Path</param> Private voidInitofficecontrol (string_sfilepath) { Try { if(M_axframercontrol = =NULL) { Throw NewApplicationException ("Please initialize the Office control object first! "); } //This.m_axFramerControl.SetMenuDisplay (48); //This method is very special, a combination menu control method, I have not found the parameters of the law, interested friends can study stringSEXT = System.IO.Path.GetExtension (_sfilepath). Replace (".",""); //This.m_axFramerControl.CreateNew (this. Loadopenfiletype (SEXT));//Create a new file This. M_axframercontrol.open (_sfilepath,false, This. Loadopenfiletype (SEXT),"","");//Open File//Hide Title This. M_axframercontrol.titlebar =false; } Catch(Exception ex) {Throwex; } } /// <summary> ///close the current interface/// </summary> Public voidClose () {Try { if( This. M_axframercontrol! =NULL) { This. M_axframercontrol.close (); } } Catch(Exception ex) {Throwex; } } //Load Excel button Private voidSbtnloading_click (Objectsender, EventArgs e) {Init (System.AppDomain.CurrentDomain.BaseDirectory+"excel\\ Project summary table. xls"); } //Close Private voidExcelform_formclosing (Objectsender, FormClosingEventArgs e) {Close (); } #endregion}
C # dsoframer.ocx How to embed excel in WinForm, inline Excel,word