package com.bovy.office;
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 ExcelTest extends Shell ...{
/** *//**
* Launch the application
*
* @param args
*/
public static void main(String args[]) ...{
Display display = Display.getDefault();
ExcelTest shell = new ExcelTest(display, SWT.SHELL_TRIM);
shell.setMaximized(true);
shell.setLayout(new FillLayout());
Menu bar = new Menu(shell, SWT.BAR);
shell.setMenuBar(bar);
OleFrame frame = new OleFrame(shell, SWT.NONE);
OleClientSite clientsite;
try {
clientsite = new OleClientSite(frame, SWT.NONE, "Excel.Sheet");
shell.layout();
clientsite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
} catch (Exception ex) ...{
System.out.println("Failed to create Excel! " + ex.getMessage());
return;
}
shell.open();
shell.layout();
while (shell != null && !shell.isDisposed()) ...{
if (!display.readAndDispatch()) ...{
display.sleep();
}
}
}
/** *//**
* Create the shell
*
* @param display
* @param style
*/
public ExcelTest(Display display, int style) {
super(display, style);
createContents();
}
/** *//**
* Create contents of the window
*/
protected void createContents() {
setText("如何在Java中访问Excel?");
setMaximized(true);
//
}
@Override
protected void checkSubclass() ...{
//
}
}
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 ExcelTest extends Shell ...{
/** *//**
* Launch the application
*
* @param args
*/
public static void main(String args[]) ...{
Display display = Display.getDefault();
ExcelTest shell = new ExcelTest(display, SWT.SHELL_TRIM);
shell.setMaximized(true);
shell.setLayout(new FillLayout());
Menu bar = new Menu(shell, SWT.BAR);
shell.setMenuBar(bar);
OleFrame frame = new OleFrame(shell, SWT.NONE);
OleClientSite clientsite;
try {
clientsite = new OleClientSite(frame, SWT.NONE, "Excel.Sheet");
shell.layout();
clientsite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
} catch (Exception ex) ...{
System.out.println("Failed to create Excel! " + ex.getMessage());
return;
}
shell.open();
shell.layout();
while (shell != null && !shell.isDisposed()) ...{
if (!display.readAndDispatch()) ...{
display.sleep();
}
}
}
/** *//**
* Create the shell
*
* @param display
* @param style
*/
public ExcelTest(Display display, int style) {
super(display, style);
createContents();
}
/** *//**
* Create contents of the window
*/
protected void createContents() {
setText("如何在Java中访问Excel?");
setMaximized(true);
//
}
@Override
protected void checkSubclass() ...{
//
}
}