cancel
Showing results for 
Search instead for 
Did you mean: 

Error while using save option in OfficeCntrol UI

sajith_p
Participant
0 Kudos

Hi Experts

I am facing issue while using OfficeControl ui in my webdynpro java application.

I am trying to save the xlsx spreadsheet data from the officecontrol UI using the below code:

try

{

IWDIOSFactory factoryInstance=null;

IWDIOSSpreadsheet documentInstance=null;

IWDAttributePointer attributePointer = wdContext.currentMiscElement().getAttributePointer("AttPointercontext");

if (factoryInstance == null)

{

IWDAttributeInfo info = wdContext.getNodeInfo().getChild("Misc").getAttribute("OCResource");

factoryInstance = WDOfficeControlMethods.getMethodHandlerInstance(info);

}

documentInstance = factoryInstance.getSpreadsheet();

IWDIOSResult iosResult = documentInstance.saveDocument(attributePointer);

}catch (Exception e) {

// TODO: handle exception

wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessage());

}

It is throwing exception "invalid message: null" on executing line factoryInstance.getSpreadsheet(). I checked that factory instance is not giving null.

Can anybody tell, why this null error is coming?

Is there any other way to save the document or calling the officecontroll save event?

I tried another work around by binding an action in the onSave of officecontrol but in that case i need to show a popup confirmation. But while using the popup it is giving below runtime error:

com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Security Violation: Root View 'PlannerCompView' not part of the active modal window 'KPDPBJBL.DialogView.Window'!

I am using CE7.1EHP1.

Highly appreciate your answers

Regards

Sajith P

Accepted Solutions (0)

Answers (1)

Answers (1)

sajith_p
Participant
0 Kudos

This has been solved myself.

The code should as follows:

public void saveExcel(){

try

{

attributePointer = wdContext.currentMiscElement().getAttributePointer("AttPointercontext");

iosResult = documentInstance.saveDocument(attributePointer);

File excelfile=new File("<Folderpath>""<file name>"".xlsx");

XSSFWorkbook wb = new XSSFWorkbook(input);

XSSFSheet sh = wb.getSheet("<Sheet name>");

FileOutputStream out = new FileOutputStream(excelfile);

//@@ Write the file in the output stream

wb.write(out);

//@@Close the output stream

out.flush();

out.close();

}catch (Exception e) {

// TODO: handle exception

wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessage());

}

}

public void closeExcel(){

//To close excel file

try

{

factoryInstance=null;

documentInstance.closeDocument(attributePointer);

}catch (Exception e) {

// TODO: handle exception

wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessage());

}

}

//@@begin others

IWDIOSFactory factoryInstance=null;

IWDIOSSpreadsheet documentInstance=null;

IWDAttributePointer attributePointer;

IWDIOSResult iosResult;

//@@end

Note: Every time if you want to open a new file in the officeui close the existing file fist.

Regards

Sajith P

Former Member
0 Kudos

Hi Sajith,

Could you please let me know how did you solved the second issue?

I am getting a similar exception in my webdynpro java application.  I am getting the below exception. Could you please help me.

com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Security Violation: Root View 'DetailedView' not part of the active modal window 'MDBJJGEN.OVSHandlerWindow.Window'!

It is a custom ESS application and when the user tried to save the address information, he is getting the above error. Not all the users are getting this error but only some of the users are experiencing this problem.


Regards

V. Suresh Kumar