openoffice.org - Opening multiple documents in a same window with UNO -


I have a script in Python, which removes data from several Excel files.

My problem is that for every file I open a window with

  url = unohelper.systemPathToFileUrl (os.path.abspath (file_name)) file = desktop And I'll stop. LoadComponentFromURL (url, "_blank", 0, ())  

and

  file.close (True)  
< P> Is there any way to remove data from files without opening a window? Or at least without opening a new window for each file?

Opens a document without displaying it:

  // Call the bootstrap to get component reference com.sun.star.uno.XComponentContext oComponentContext = null; Try {String oooExeFolder = "C: / Program Files / OpenOffice.org 3 / Program /"; OComponentContext = BootstrapSocketConnector.bootstrap (oooExeFolder); } Hold (com.sun.star.comp.helper.BootstrapException pre) {System.out.println (ex.getMessage ()); } If (oComponentContext! = Null) {com.sun.star.lang.XComponent oComponent; Com.sun.star.sheet.XSpreadsheetDocument Opsdate document; Com.sun.star.frame.XComponentLoader oComponentLoader; {Com.sun.star.lang.XComponent oComponent; // service manager com.sun.star.lang.XMultiComponentFactory oMultiComponentFactory = oComponentContext.getServiceManager (); // Create a new desktop instance Object ODesktop = Omalty Componentifier.CredibleInstanceWindContact ("Com.Star.frame.desktop", Occantent Contex); // Create a new component loader within our desktop oComponentLoader = (com.sun.star.frame.XComponentLoader) com.sun.star.uno.UnoRuntime.queryInterface (com.sun.star.frame.XComponentLoader.class, oDesktop) ; /// File created com.sun.star.beans.PropertyValue [] Property = New com.sun.star.beans.PropertyValue Read [2]; Property [0] = New Com. Sun.star.beans.PropertyValue (); Property [0] .name = new string ("read only"); Property [0]. Value = new boolean (true); Property [1] = New Comm. Sun.Star.bins.Property Value (); Property [1] .name = new string ("hidden"); Property [1]. Value = new boolean (true); OComponent = oComponentLoader.loadComponentFromURL ("file: /// c: /test/sheetdoc.ods", // "private: factory / sweater", // blank document "_default", // new frame 0, // no search No flags // read only the property); // Spread Sheet Oaspread Document = (com.sun.star.sheet.XSpreadsheetDocument) com.sun.star.uno.UnoRuntime.queryInterface (com.sun.star.sheet.XSpreadsheetDocument.class, oComponent); } Hold (Exception Pre) {System.out.println ("An exception is on opening the document:" + ex.getMessage ()); Return; }} // if of system.exit (0);  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -