Show TOC Start of Content Area

Procedure documentation Using OfficeControl  Locate the document in its SAP Library structure

This example shows how you can use OfficeControl to integrate an Office document in a Web Dynpro application.

Use

OfficeControl is used in a Web Dynpro application that is used for a defined group of users, as the relevant Office program needs to be installed on the client.

If you have problems displaying OfficeControl, it might help to check whether ActiveX Control Framework (ACF) has been correctly installed. For details, see SAP Note 846952.

Prerequisites

You have created a Web Dynpro project including component, window and view.

In this example, a file called word.doc is read. The file is stored in Mime Repository in directory <project name>/src/mimes/Components/<component name>. If you do so, you can refer to this file without specifying a directory.

Procedure

Creating the context

...

       1.      Create a Node called Src and an attribute called dataSrc. This context attribute is used to store the file content.

, This graphic is explained in the accompanying text

       2.      Set the property Type of the dataSrc attribute to Resource as shown in the screenshot below.

This graphic is explained in the accompanying text

More information: Binding resource Property

       3.      Create a context attribute called visible of type Visibility.

       4.      To store the relevant file in the context, insert the following code into the wdDoInit method:

wdDoInit()

IPrivateMyView.ISrcElement element = wdContext.nodeSrc().createAndAddSrcElement();

   String filename = "";

try

   {

   filename = WDURLGenerator.getResourcePath(
      
wdComponentAPI.getDeployableObjectPart().getWebModule(), "word.doc");

   element.setDataSrc(WDResourceFactory.createMassDataResource(new
       FileInputStream(filename),WDWebResourceType.DOC));

   }

   catch (FileNotFoundException e)

   {

      throw new WDRuntimeException("No datasource available");}

 

 

Creating an OfficeControl in the view

...

       1.      Insert an OfficeControl into the view.

       2.      Bind the dataSource property of the OfficeControl to the context attribute dataSrc.

       3.      Bind the visible property of the OfficeControl to the context attribute visible.

Result

if you set the Visibility to VISIBLE, the Microsoft word document will be displayed. If you set the visibility to NONE, the word document will be closed and the event onClose will be triggered.

End of Content Area