Oracle COM Automation Feature Developer's Guide Release 9.2 Part Number A95499-01 |
|
This chapter describes how to use the demonstration program designed for Oracle COM Automation Feature for Java.
This chapter contains these topics:
Oracle COM Automation Feature for Java includes an example that demonstrates how to use the feature to build solutions. The demo provides base functionality and can serve as a foundation on which to build more customized, complex applications that use COM Automation. This demo is based on the human resources schema available with the sample schema.
The demo exposes a core set of APIs that enable you to do simple operations using COM Automation Feature. Each COM Automation server, such as Word and Excel, provides more advanced capabilities than what is offered through the demo APIs. To take advantage of these advanced features, you must design and code your own Java classes.
In this release, Oracle Corporation has provided the following demo:
The following sections describe how to install the Microsoft Word Java demo and the APIs that it exposes. This demo is provided as an example of the types of solutions that can be built with Oracle and Microsoft Word.
The demo creates a Microsoft Word document containing the names of employees in the database.
The Microsoft Word Java demo is installed in the ORACLE_BASE\ORACLE_HOME
\com\java\demos
directory and provides the following:
TestWORD.java
, the Java source for the demo. In addition to the collection of APIs, it includes the demo program test
.TestWORD.class
, the Java class for the demo.TestWORD.sql
, the script which creates the call spec for the demo.Microsoft Word must be installed on the local computer before installing this demo.
To install the demo:
loadjava
from the command line:loadjava -force -resolve -user hr/hr ORACLE_BASE\ORACLE_ HOME\com\java\demos\TestWORD.class
C:\>SQLPLUS
SQL> connect hr/hr
TestWORD.sql
to create the call spec:SQL>@
ORACLE_BASE\ORACLE_HOME\com\java\demos\TestWORD.sql
See Also:
|
To use the Word demo:
SERVEROUTPUT
on at the SQL*Plus prompt:SQL> SET SERVEROUTPUT ON
TestWORD()
at the SQL*Plus prompt:
SQL> CALL TestWORD();
This creates a Microsoft Word document (worddemoj.doc
) in the C:\directory. The document contains data from the EMPLOYEES
and JOBS
tables. These tables are available in the human resources schema in the sample schema.
wordemoj.doc
to see its contents.public class TestWORD
as described in "Core Functionality" , provides a wrapper around the Word.Basic COM Automation class as well as some sample code which demonstrates how to use the wrapper. This code was written to be run on the Oracle database server.
To create a custom application which uses this wrapper:
CreateWordObject
.FileNew
, or open an existing document with the method FileLoad
.FormatFontSize
, InsertText
, InsertNewLine
to add text and formatting to the document.FileSaveAs
or FileSave
.FileClose
when you are finished with the document.DestroyWordObject
when you are finished with the Word.Basic object.The following subsections describe the APIs that the Microsoft Word Java demo exposes. These APIs are primitive. Be aware that much of the functionality that Microsoft Word exposes through COM Automation is not exposed through these APIs.
The constructor. It does nothing.
public TestWORD()
Creates the Word.Basic COM object.
public void CreateWordObject(java.lang.String servername)
Where | Is |
---|---|
servername |
the server on which to create the COM object. Specify null or the empty string for the local server. |
Destroys the Word.Basic COM object.
public void DestroyWordObject()
Creates a new Microsoft WORD document.
public void FileNew()
Wrapper for the FileNewDefault
COM method of the Word.Basic COM object.
Loads an existing Microsoft WORD document.
public void FileLoad(java.lang.String filename)
Where | Is |
---|---|
|
the name of the file to load. |
Wrapper for the FileOpen
COM method of the Word.Basic COM object.
Sets the font size.
public void FormatFontSize(long fontsize)
Where | Is |
---|---|
|
the new font size. |
Wrapper for the FormatFont
COM method of the Word.Basic COM object.
Inserts text into the Microsoft Word document.
public void InsertText(java.lang.String textstr)
Where | Is |
---|---|
|
the text to insert. |
Wrapper for the Insert
COM method of the Word.Basic COM object.
Inserts a newline into the Microsoft Word document.
public void InsertNewLine()
Wrapper for the InsertPara
COM method of the Word.Basic COM object.
Saves the Microsoft Word document using a specified name.
public void FileSaveAs(java.lang.String filename)
Where | Is |
---|---|
|
the name of the file. |
Wrapper for the FileSaveAs
COM method of the Word.Basic COM object.
Saves the Microsoft Word document.
public void FileSave()
Wrapper for the FileSave
COM method of the Word.Basic COM object.
Closes the Microsoft Word document, and exits Microsoft Word.
public void FileClose()
Wrapper for the FileClose
and FileExit
COM methods of the Word.Basic COM object.
|
Copyright © 1999, 2002 Oracle Corporation. All Rights Reserved. |
|