Merci pour votre réponse,
J'ai oublié de dire que j'essaie de faire cette création avec une macro.
De plus, l'url n'est pas la même pour une création de fichier et une
ouverture de fichier.
J'ai besoin de connaître le protocole de création du fichier.
Cyrille
Emilie Basso a écrit :
voici comment ouvrir un fichier éxistant :
public class tests2
{
private XComponentLoader xComponentLoader = null;
private XComponentContext xRemoteContext = null;
private XMultiComponentFactory xRemoteServiceManager = null;
private XComponent xWriterComponent;
/** crée une nouvelle instance de tests */
public tests2() {}
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
tests2 test = new tests2();
try
{
test.useDocuments();
}
catch (java.lang.Exception e)
{
System.err.println(e.getMessage());
e.printStackTrace();
}
finally
{
System.exit(0);
}
}
protected void useDocuments() throws java.lang.Exception
{
useWriter();
}
protected void useWriter() throws java.lang.Exception {
try
{
// create new writer document
xWriterComponent = newDocComponent();
}
catch( com.sun.star.lang.DisposedException e )
{
//works from Patch 1
xRemoteContext = null;
throw e;
}
}
protected XComponent newDocComponent(String docType) throws
java.lang.Exception
{
String loadUrl ; /*= "private:factory/swriter" pour
ouvrir un document vierge*/
xRemoteServiceManager = this.getRemoteServiceManager();
Object desktop =
xRemoteServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop",
xRemoteContext);
xComponentLoader =
(XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class,
desktop);
PropertyValue[] loadProps = new PropertyValue[1];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "Hidden";
loadProps[0].Value = new Boolean (false); //true pour
cacher l'ouverture de l'application
loadUrl = "file:///C:/fichier.odt";
// load
return xComponentLoader.loadComponentFromURL(loadUrl,
"_blank", 0, loadProps);
}
protected XMultiComponentFactory getRemoteServiceManager()
throws java.lang.Exception {
if (xRemoteContext == null && xRemoteServiceManager == null)
{
// First step: get the remote office component context
xRemoteContext =
com.sun.star.comp.helper.Bootstrap.bootstrap();
System.out.println("Connected to a running office ...");
xRemoteServiceManager =
xRemoteContext.getServiceManager();
}
return xRemoteServiceManager;
}
en espérant que ça t'aide...
From: Cyrille de Lambert <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: [prog] creation fichier texte
Date: Fri, 09 Jun 2006 16:29:21 +0200
Bonjour,
Je n'arrive pas à trouver la liste des protocoles pour le paramètre
*URL* de la fonction *loadComponentFromURL* création de nouveau
document.
Je cherche à créer un document texte (csv) afin de faire un export de
données.
Merci d'avance pour votre aide
_________________________________________________________________
Windows Live Mail : venez tester la version bêta !
http://www.ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]