Eclipse version in use: 3.3.1
JDK version used: 5.0
Packagecom.jrkui.example.excel;
import Org.eclipse.swt.SWT;
Import org.eclipse.swt.layout.FillLayout;
Import Org.eclipse.swt.ole.win32.OLE;
Import Org.eclipse.swt.ole.win32.OleClientSite;
Import Org.eclipse.swt.ole.win32.OleFrame;
Import Org.eclipse.swt.widgets.Display;
Import Org.eclipse.swt.widgets.Menu;
Import Org.eclipse.swt.widgets.Shell;
public class Excelshell {
public static void Main (string[] args) {
New Excelshell (). Open ()
public void Open ()
{
Display display = Display.getdefault ();
Shell shell = new Shell ();
Shell.setsize (600,400);
Shell.settext ("Excel window");
Shell.setlayout (New Filllayout ());
//Show Excel's Menu bar
Shell.setmenubar (New menu, SHELL,SWT. BAR));
Createexcelpart (shell);
Shell.open ();
while (!shell.isdisposed ()) {
if (!display.readanddispatch ())
Display.sleep (); br>}
DisplaY.close ();
}
/**
* Make excel embedded in the shell
* @param Shell
*/
private void Createexcelpart (shell Shell)
{
//oleframe is actually a composite that is used to place the OLE control
Oleframe oleframe = new Oleframe (SHELL,SWT. NONE); The
//oleclientsite provides a place for embedding OLE objects into containers where the OLE object represented by "Excel.Sheet" is Excel
oleclientsite clientsite = new O Leclientsite (OLEFRAME,SWT. NONE, "Excel.Sheet");
//oleclientsite The action that is done when the OLE object is displayed, where the action is oleiverb_show, representing the display
Clientsite.doverb OLE. Oleiverb_show);
}
}