Hi ALL,
I come to a conclusion.
This code start a .xls file (if it exists).
I accept any advice.

public class LoadExcel {
/[EMAIL PROTECTED] null if url don't exists*/ public static XModel startExcelFile(String urlExcelFile)throws java.lang.Exception{
       /**Bootstrap*/
com.sun.star.uno.XComponentContext contestoRemoto = com.sun.star.comp.helper.Bootstrap.bootstrap();
       System.out.println("Connected to a running office ...");
com.sun.star.lang.XMultiComponentFactory serviceManager = contestoRemoto.getServiceManager(); String available = (serviceManager != null ? "available" : "not available");
       System.out.println( "remote ServiceManager is " + available );
       /***/
Runtime r = Runtime.getRuntime();
       Process p = r.exec("soffice -calc "+urlExcelFile);
XInterface xi = (XInterface)serviceManager.createInstanceWithContext("com.sun.star.frame.Desktop",contestoRemoto); XDesktop xdesk = (XDesktop)UnoRuntime.queryInterface(XDesktop.class,xi);
       return getModelURL(xdesk,urlExcelFile);
   }
/[EMAIL PROTECTED] null if url don't exists*/ private static XModel getModelURL(XDesktop xdesk, String url)throws java.lang.Exception{
       String sURL = url.trim().toLowerCase();
       XEnumerationAccess xea = xdesk.getComponents();
       XEnumeration xe = xea.createEnumeration();
       XModel currentModel = null;
       boolean exists = false;
       while(xe.hasMoreElements() && exists==false){
currentModel = (XModel)UnoRuntime.queryInterface(XModel.class,xe.nextElement()); exists = currentModel.getURL().trim().toLowerCase().equals(sURL); } if(exists){
           return currentModel;
       }
       else{
           return null;
       }
   }

}

Regards, Vincenzo.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to