cancel
Showing results for 
Search instead for 
Did you mean: 

How to Show excel in my app?

Former Member
0 Kudos

I see a demo in my server with url : http://hdkj:50000/webdynpro/dispatcher/sap.com/bialvtestapps/ALVTestWithExternalDialog

I select Excel Inplace Allowed and start it ,then it has a menu with names Ms Excel,and it can show data with exccel.

(If those demo hava resource code?)

1.I know how to get data from context, but I don't know how to show excel dynamic(I kown how to show excel local)....

2.And There has a table is used for config table ,such as which column will be show. How can do it?

Anyone can help me? (Can Visual Composer implement it ? OR Alv? I Don't Know about it)

Thanks very much!

Edited by: fun HOW on Apr 23, 2008 8:05 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I meant

try {

ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());

IWDResource resource = WDResourceFactory.createCachedResource(os.toByteArray(), "1.xls", WDWebResourceType.XLS);

if (resource != null) {

wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.getUrl(WDFileDownloadBehaviour.OPEN_INPLACE.ordinal()),"1.xls").show();

}

//wdContext.currentContextElement().setResource(resource);

//INodeBinaryElement element = wdContext.nodeNodeBinary().createAndAddNodeBinaryElement();

//element.setBinaryResource(os.toByteArray());

} catch (Exception e) {

e.printStackTrace();

}

Keep the file name of xls as 1.xls and not just 1.

Thanks.

Former Member
0 Kudos

Hi.

Thanks for your help.

Now I can open excel in ie. But it still doesn't work with OfficeControl.

I guess it the Version of POI created file can't work in OfficeControl.

I set the Theard as answered. If you get the Points? I don't know if I have points.

Where i can down Netweaver NW_JAVA_700SP14_SR3.rar(4GB)? In SDN ,it can't download.

Edited by: fun HOW on Apr 24, 2008 9:28 AM

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I have not come accross any error like this and i should see whether can replicate it. Any ways.

Can you check whether the excel sheet is getting created properly. This way we will know which is causing the issue and concentrate accordingly.

Try this with your code

try {

ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());

IWDResource resource = WDResourceFactory.createCachedResource(os.toByteArray(), "abc.xls", WDWebResourceType.XLS);

//wdContext.currentContextElement().setResource(resource);

//INodeBinaryElement element = wdContext.nodeNodeBinary().createAndAddNodeBinaryElement();

//element.setBinaryResource(os.toByteArray());

} catch (Exception e) {

e.printStackTrace();

}

Former Member
0 Kudos

Hi,

In webdynpro java, You can create a method which will populate the Records of table in a xml format , i.e

x.append("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n");

x.append("<").append(entryName).append(">\n");

and so on..

Use this string which will have data interms of xml format to create a excel sheet.

IWDResource cachedWebResource = WDResourceFactory.createCachedResource(excelXMLFile, fileName, WDWebResourceType.XLS);

Hope this helps.

Former Member
0 Kudos

Thanks for you answer.

I know how to create a xml file with Tpye IWDResource and use download() method to download that file.

But I want show it with a OfficeControl in a view . I read a xml file local then transform to byte[] and binding with OfficeControl . But it's does not work.

Then I used a Third Tool names POI,it can create a Excel file. I transform it to byte[] and binding with OfficeControl,it's does not work .And it has a error:

ERRO|20080424100407|KHFA.OfficeCompView.OfficeControl_5140|CIOS_GeneralDocumentContainer_Acf::|OleLoad|HRESULT=-2147221164(&#27809;&#26377;&#27880;&#20876;&#31867;&#21035;)

I do't know why?

Code:


		ByteArrayOutputStream os = new ByteArrayOutputStream();
		HSSFWorkbook wb = null;
		wb = new HSSFWorkbook();
		HSSFSheet s = wb.createSheet();
		wb.setSheetName(0, "Matrix");
		HSSFRow row = s.createRow(0);
		HSSFCell cell = row.createCell((short) 0);
		cell.setCellValue("POI test");
		try {
			wb.write(os);
		} catch (IOException e) {
			e.printStackTrace();
		}

		try {
			ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
			IWDResource resource = WDResourceFactory.createCachedResource(os
					.toByteArray(), "1", WDWebResourceType.XLS);
			
			wdContext.currentContextElement().setResource(resource);
			INodeBinaryElement element = wdContext.nodeNodeBinary().createAndAddNodeBinaryElement();
			element.setBinaryResource(os.toByteArray());
		} catch (Exception e) {
			e.printStackTrace();
		}