Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

We can use Office UI Element to work with office documents. I would like to explain with a very simple example.Lets take a scenario where you want to open and close a document in WebDynpro

Pre-requisite :Place the document that you want to open in mimes folder of the WebDynpro project

Follow the steps below

1. Create a OfficeControl on the view

2. Create a valueAttribute in the context and set the type to binary

3. Set the datasource of the officecontrol to the above valueattribute

4. Create three buttons labled as "New" , "Open" and "Close" as shown below

5. Write the following code in the wdDoInit() method. The following code will read the file that we want to open , convert the file to byte array and set the byte array to the value attribute which is a datasource to the office UIElement



6. Declare the following as public variables
  • public IWDIOSFactory factoryInstance;
  • public IWDIOSDocument documentInstance;

In the above code getBytesFromFile() is method which returns byte array. Find the code for the same.

Now we have the context ready and we set the context to the existing document .We will place a button with label "Open" and the requirement is when you click on the "Open" button it should show the document in the Office UIElement.Paste the following code in the "Open" button action handler



Now create one more button labled as "New" ,on click of this button the officeDocument control should open a new document.So to do this paste the following code in the action handler of "New" button



Create a button with label "Close" and write the following code in the Close action handler



The final application will look like the following



In my next web log we will see how we can use OfficeUIElement with FileUpload control so that user can select and open the documents dynamically
6 Comments