This Question is Answered

2 "helpful" answers available (2 pts)
4 Replies Last post: Jan 15, 2010 11:17 AM by Enrique  
Enrique   3 posts since
Jan 14, 2010
Currently Being Moderated

Jan 14, 2010 2:10 PM

Display documents

Hello,

 

We are developing a java application which needs to display MSOffice documents and PDF´s inside a Java frame. We have downloaded the comfyJ demo to test it before purchasing a license but we are really confused. We have been able to generate the different stubs and executed the samples but we don't know how to customize the code.

What we really need is simply open a document in our hard disk. For instance, the “ExcelIntegrationSample” opens a new worksheet containing some data but we are not able to specify our document and open it.

 

The four documents in the “docs” folder (programmer’s guide and tutorial for ComfyJ and JNIWrapper) were read but we didn’t find the solution.

 

We will be very grateful if someone could help us. We would like to have an example properly working before getting a license.

 

Thanks in advance.

Enrique

Serge Piletsky TeamDev Ltd. 1,066 posts since
Apr 24, 2006
Currently Being Moderated
1. Jan 14, 2010 3:41 PM in response to: Enrique
Re: Display documents

Hi Enrique,

We have been able to generate the different stubs and executed the samples but we don't know how to customize the code.

What do you mean by "how to customize the code"? Do you need to do something that is not demonstrated by the examples? If so, then I think it should be mentioned here that ComfyJ is just the Java COM bridge which allows integrating with different COM libraries. It does not provide the complete solutions for integrations with any particular product, simply because it's not possible. That is why our samples demonstrates only the basics of API usage. And if you need the further integration with a particular COM library (such as MS Word or any other) then definitely you need to know the API of the product which you are going to use.

For instance, the “ExcelIntegrationSample” opens a new worksheet containing some data but we are not able to specify our document and open it.

Well, that sample is designed to demonstrate how to open different excel documents. Please clarify - you cannot specify your document in a open file dialog (perhaps because there is no appropriate filter in it)? Or you are getting some exception during opening a file?

The four documents in the “docs” folder (programmer’s guide and tutorial for ComfyJ and JNIWrapper) were read but we didn’t find the solution.

Those were not intended to provide the particular solutions for integration with MS Word API or something else. They were designed to demonstrate different techniques and product usage.

 

-Serge

Serge Piletsky TeamDev Ltd. 1,066 posts since
Apr 24, 2006
Currently Being Moderated
3. Jan 14, 2010 7:41 PM in response to: Enrique
Re: Display documents

Hi Enrique,

 

Of course it's possible.

 

In order to open an Excel document you can use one of the following approaches:

 

1) Open a document using the OleContainer.createObject(File) method. For example, in the ExcelIntegrationSample.java class you need to change one line only:

// _container.createObject(DOCUMENT_PROGID);
_container.createObject(new File("C:\\FileName.xls"));

 

2) Open a required document via Excel API, using the generated stubs:

_Application application = getApplication();
Workbooks workbooks = application.getWorkbooks();
Variant unspecified = Variant.createUnspecifiedParameter();
workbooks.open(new BStr("C:\\FileName.xls"),
        unspecified,
        unspecified,
        unspecified,
        unspecified,
        unspecified,
        unspecified,
        unspecified,
        unspecified,
        unspecified,
        unspecified,
        unspecified,
        unspecified,
        unspecified,
        unspecified,
        new Int32(0));

3) Open a required document using Automation:

IDispatch workbooks = ...;
 
Automation workbooksAutomation = new Automation(workbooks, true);
workbooksAutomation.invoke("open", "C:\\FileName.xls");

 

Please let me know if you have another questions.

 

-Serge

More Like This

  • Retrieving data ...