Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » how to fix the size of Excel OLE object
how to fix the size of Excel OLE object [message #444971] Fri, 22 October 2004 17:50
Eclipse UserFriend
Originally posted by:

I am using the SWT OLE package to embed an Excel.Sheet. (See code below).

How do I make sure the OLE object fits inside its parent and remains at a
fixed size? By this, I mean I would like the object's behavior to be
similar to that if I would start MS Word and insert an Excel Sheet---the
sheet appears in the middle of the page with scrollbars, but does not
resize unless explicitly done so with the side handles.

If you run the example below, the Excel Sheet does not fit within the
Shell (you cannot see the vertical scrollbar), and has even stranger
behavior when the Display/Shell is resized.

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.ole.win32.*;

public class Embed {

* Comment for <code>serialVersionUID</code>
private static final long serialVersionUID = 1L;

public static void init(Shell shell) {

OleFrame frame = new OleFrame(shell, SWT.BORDER);

OleClientSite site;
try {

site = new OleClientSite(frame, SWT.NONE, "Excel.Sheet");


} catch (org.eclipse.swt.SWTException e) {
String str = "Create OleClientSite Error" + e.toString();

public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());

Menu bar = new Menu (shell, SWT.BAR);
shell.setMenuBar (bar);

// create and activate the OLE object
init(shell); ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
display.dispose ();
Previous Topic:Some questions about TableTree
Next Topic:Drang And Drop Arbitrary Objects
Goto Forum:

Current Time: Fri Oct 30 03:10:36 GMT 2020

Powered by FUDForum. Page generated in 0.01671 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top