Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] Hiding menus and toolbars from Excel Sheet

Hi,

I'm very new to Java development, specially to SWT and OLE.

I used OleClientSite to display an Excel sheet on SWT shell. Though it displays fine, but my requirement is not to show any Excel menus and Tool bars so that user should not be able to save or apply formating etc. I have also read different answers at the mailing list and snippets at http://www.eclipse.org/swt/snippets/     that OleControlSite should be used for this purpose but still this does not solve my problem. Because still I can see the menus and toolbars, also the contents of my excel sheet does not get loaded and all the cells appear blank.

Can anybody help to solve this problem? Some code will be very helpful for me.
I have office 2007,  SWT 3.3.1 and JDK 5 installed. Below is my code:

public class Try2 {
    private Shell shell;
   
    static OleClientSite clientSite;
      
    public Shell open(Display display){
        this.shell=new Shell(display, SWT.MIN);
       
        final Button saveChangesButton = new Button(shell, SWT.NONE);
        saveChangesButton.setText("Save Changes");
        saveChangesButton.setBounds(64, 405, 93, 23);
               
        OleFrame frame = new OleFrame(shell,SWT.NONE);
        frame.setBounds(0, 0, (shell.getSize().x)-5, 400);
        final File file= new File("D:/Work/Worksheet1.xls");
        try{
            clientSite =  new OleClientSite(frame, SWT.NONE, file);
            this.shell.layout();
           
            clientSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
           
       }catch(SWTException ex)
       {
           System.out.println(ex.getMessage());
           return null;
       }
       
        Listener saveChangesButtonListner = new Listener() {
            public void handleEvent(Event event) {
               
                if(clientSite.isDirty())
                    clientSite.save(file, true);
            }
        };
       
        saveChangesButton.addListener(SWT.Selection, saveChangesButtonListner);

        shell.open();
        return  shell;
    }
   
    /**
     * @param args
     */
    public static void main(String[] args) {
       
        Display display=new Display();
        Shell shell=(new Try2()).open(display);
        while(!shell.isDisposed()){
            if(!display.readAndDispatch()){
                display.sleep();
            }
        }
        clientSite.dispose();
        display.dispose();

    }
 
}


Connect to the next generation of MSN Messenger  Get it now!

Back to the top