Compiling the sample program ============================ Set up your CLASSPATH environment variable as follows (substitute the path to your OpenOffice.org installation for /export/home/staroffice below): % setenv CLASSPATH ${CLASSPATH}:/export/home/staroffice/program/classes/jurt.jar:/export/home/staroffice/program/classes/ridl.jar:/export/home/staroffice/program/classes/sandbox.jar:/export/home/staroffice/program/classes/unoil.jar:/export/home/staroffice/program/classes/juh.jar:. Now compile the sample program: % javac MailMerger.java Running the sample program ========================== First start OpenOffice.org from the command line with the -accept flag: % /export/home/staroffice/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" Note: If you use a different port than 8100, you will need to change the DEFAULT_CONNECTION_STRING variable in MailMerger.java and recompile. Copy the values.csv file into a directory on your machine eg. /export/home/csv The MailMerger program takes two possible flags: % java MailMerger -create >URL of Data Source directory& >URL to save template file& >Data Source name& >Table name& The Data Source directory paramter is a file URL and should point to the directory where your .csv files are stored eg. ///export/home/csv The template file URL should have the extension .stw to specify that it is a OpenOffice.org template you want stored eg. ///export/home/mytemplate.stw The Table name parameter should be the name of one of the tables stored in your Data Source directory (each .csv file in the directory is treated as a table, it's name is the filename with the .csv extension removed). So the command will look something like: % java MailMerger -create ///export/home/csv ///export/home/mytemplate.stw mydatasource values This command will: fields in the Writer document name provided You can then run a MailMerge as follows: % java MailMerger -merge >URL of template file& >Data Source name& >Table name& This will perform a MailMerge using the template file, data source and table names provided. These should be the same names that you used in the -create command So the corresponding command for the -create example above would be: % java MailMerger -merge ///export/home/mytemplate.stw mydatasource values Further Information =================== http://api.openoffice.org/DevelopersGuide/DevelopersGuide.html The First Steps chapter gives a good understanding of the basic concepts behind the OpenOffice.org API. references to the sections of the Developer Guide which cover the APIs used in the program. http://api.openoffice.org/common/ref/com/sun/star/module-ix.html http://www.openoffice.org/dev_docs/source/sdk/index.html This SDK will be the basis of the OpenOffice.org SDK. It contains examples which help you to get started with writing Java programs for the OpenOffice.org API. Example contents of values.csv file ========================= Name,Address,Telephone Joe,Kerry,9933339 Tom,Dublin,9988888 |