Excel in SWT [message #462802] |
Wed, 19 October 2005 17:22 |
Eclipse User |
|
|
|
Originally posted by: rigolet.j.fr.ibm.com
This is a multi-part message in MIME format.
--------------000508010506070002030503
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Is there a working sample of a viewpart displaying & editing a an Excel
file somewhere?
We tried different things & the best we get was by embedding the OLE
object within the IE browser. Doing so, we couldn't get any Excel
toolbar - toolbar we could have by just creating the ole frame in the
view - but this time without any access to the xls file.
Remark: we also want to programatically read & make updates to the xls
content.
Thank you.
Attached is the view we're using.
--------------000508010506070002030503
Content-Type: text/plain;
name="View.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="View.java"
package jPMCDesktop;
import java.io.File;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleControlSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.part.ViewPart;
public class View extends ViewPart {
public static final String ID = "JPMCDesktop.view";
private String PROGRAM_ID = "Excel.Sheet";
/**
* This is a callback that will allow us to create the viewer and initialize
* it.
*/
public void createPartControl(Composite parent) {
OleFrame frame = new OleFrame(parent, SWT.NONE);
Shell shell = parent.getShell();
Menu bar = new Menu(shell, SWT.BAR);
MenuItem fileItem1 = new MenuItem(bar, SWT.CASCADE);
fileItem1.setText("File Item 1");
MenuItem fileItem2 = new MenuItem(bar, SWT.CASCADE);
fileItem1.setText("File Item 2");
MenuItem containerItem = new MenuItem(bar, SWT.CASCADE);
containerItem.setText("Container Item");
MenuItem windowItem1 = new MenuItem(bar, SWT.CASCADE);
windowItem1.setText("Window Item 1");
MenuItem windowItem2 = new MenuItem(bar, SWT.CASCADE);
windowItem2.setText("Window Item 2");
frame.setFileMenus(new MenuItem[] { fileItem1, fileItem2 });
frame.setContainerMenus(new MenuItem[] { containerItem });
frame.setWindowMenus(new MenuItem[] { windowItem1, windowItem2 });
File file = new File("C://Conges.XLS");
OleClientSite clientSite = new OleClientSite(frame, SWT.NONE, file);
clientSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
}
/**
* Passing the focus request to the viewer's control.
*/
public void setFocus() {
}
}
--------------000508010506070002030503--
|
|
|
Re: Excel in SWT [message #462803 is a reply to message #462802] |
Wed, 19 October 2005 17:34 |
Eclipse User |
|
|
|
Originally posted by: friederich.kupzog.de
Sorry, no idea about the OLE side of the problem. But for
programatically accessing Excel files, the following is useful:
http://www.andykhan.com/jexcelapi/
Regards,
Friederich
JYR wrote:
> Is there a working sample of a viewpart displaying & editing a an Excel
> file somewhere?
> We tried different things & the best we get was by embedding the OLE
> object within the IE browser. Doing so, we couldn't get any Excel
> toolbar - toolbar we could have by just creating the ole frame in the
> view - but this time without any access to the xls file.
>
> Remark: we also want to programatically read & make updates to the xls
> content.
>
> Thank you.
>
>
> Attached is the view we're using.
>
>
> ------------------------------------------------------------ ------------
>
> package jPMCDesktop;
>
> import java.io.File;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.SWTException;
> import org.eclipse.swt.ole.win32.OLE;
> import org.eclipse.swt.ole.win32.OleClientSite;
> import org.eclipse.swt.ole.win32.OleControlSite;
> import org.eclipse.swt.ole.win32.OleFrame;
> import org.eclipse.swt.widgets.Composite;
> import org.eclipse.swt.widgets.Menu;
> import org.eclipse.swt.widgets.MenuItem;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.ui.part.ViewPart;
>
> public class View extends ViewPart {
> public static final String ID = "JPMCDesktop.view";
>
> private String PROGRAM_ID = "Excel.Sheet";
>
> /**
> * This is a callback that will allow us to create the viewer and initialize
> * it.
> */
> public void createPartControl(Composite parent) {
> OleFrame frame = new OleFrame(parent, SWT.NONE);
>
> Shell shell = parent.getShell();
> Menu bar = new Menu(shell, SWT.BAR);
>
> MenuItem fileItem1 = new MenuItem(bar, SWT.CASCADE);
> fileItem1.setText("File Item 1");
> MenuItem fileItem2 = new MenuItem(bar, SWT.CASCADE);
> fileItem1.setText("File Item 2");
>
> MenuItem containerItem = new MenuItem(bar, SWT.CASCADE);
> containerItem.setText("Container Item");
>
> MenuItem windowItem1 = new MenuItem(bar, SWT.CASCADE);
> windowItem1.setText("Window Item 1");
> MenuItem windowItem2 = new MenuItem(bar, SWT.CASCADE);
> windowItem2.setText("Window Item 2");
>
> frame.setFileMenus(new MenuItem[] { fileItem1, fileItem2 });
> frame.setContainerMenus(new MenuItem[] { containerItem });
> frame.setWindowMenus(new MenuItem[] { windowItem1, windowItem2 });
>
> File file = new File("C://Conges.XLS");
> OleClientSite clientSite = new OleClientSite(frame, SWT.NONE, file);
> clientSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
>
> }
>
> /**
> * Passing the focus request to the viewer's control.
> */
> public void setFocus() {
> }
> }
--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01686 seconds