This example shows how you can use OfficeControl to integrate an Office document in a Web Dynpro application.
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.
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.
Creating the context
More information: Binding resource Property
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
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.