Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

problem in downloading data into excel.

Dear all,

I have a requirement to download a report into excel .I used link to url and used below code for downloading the report into excel.


Map m = new HashMap();
	
		//IWDNode  wdTableNode = wdContext.nodeItab_Report2();
		IWDNode  wdTableNode = null;
		int type1 = type;
						wdTableNode = wdContext.nodeItab_Report1();
					
 
		
		byte[] b = null;
		String linktoFile = null;
		StringBuffer err = new StringBuffer();
		StringBuffer xml_file = new StringBuffer();
			
		int noofelem = wdTableNode.size();
			
		ArrayList columnInfos = trimHeaderTexts(columnInfos1);
	
		String nodename = wdTableNode.getNodeInfo().getName().trim();
		String _nodename = nodename.substring(0, 1).toUpperCase()+nodename.substring(1).toLowerCase();
	
		xml_file.append("<?xml version='1.0' encoding='UTF-8' standalone='no'?><")
					.append(_nodename)
					.append(">\n");
				
		int size = columnInfos.size();
	
		for(int i =0;i<noofelem;i++)
		{	
				IWDNodeElement elem = wdTableNode.getElementAt(i);
				xml_file.append("<")
						.append(_nodename)
						.append("Element>");
			
				for (int j = 0;j<columnInfos.size();j++)
				{
					String attributeName = (String)columnInfos.get(j);
					String attributeValue = "";
					if(elem.getAttributeValue(attributeName)!=null)
						attributeValue = elem.getAttributeValue(attributeName).toString().trim();
					xml_file.append("<")
							.append(attributeName)
							.append(">")	
//							.append(elem.getAttributeValue(attributeName))
							.append(attributeValue)
							.append("</")
							.append(attributeName)
							.append(">\n");
						
				}
				xml_file.append("</")
						.append(_nodename)
						.append("Element>\n");
					
		}
		xml_file.append("</")
			.append(_nodename)
			.append(">\n");
		
		
	
			try 
			{
					b =  xml_file.toString().getBytes("UTF-8");
					IWDCachedWebResource xlfile = WDWebResource.getWebResource(b,WDWebResourceType.XLS);
					xlfile.setResourceName(this.getDropdownText()+" Report ");
				//xlfile.
					linktoFile = xlfile.getURL();
					
					
					IWDWindow win = wdComponentAPI.getWindowManager().createExternalWindow(xlfile.getURL(),"Service Request Details",true);
					win.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);
					win.removeWindowFeature(WDWindowFeature.TOOL_BAR);
					//win.removeWindowFeature(WDWindowFeature.MENU_BAR);
					win.removeWindowFeature(WDWindowFeature.STATUS_BAR);
					win.show();			
			}	
			catch (WDURLException e1) 
			{
				err.append(""+e1.getCause());
			}
			catch (UnsupportedEncodingException e) 
			{
				err.append(""+e.getCause());
			} 
		m.put("data",b);
		m.put("url",linktoFile);
		m.put("error",""+err.toString());
    	
	}
	catch(Exception e)
	{
		this.catchMessage("E","Download To Excel"+e.toString());
	}
	return m;    

evrything is fine.One column is having text.If the text size is more than 255 chars the total text is displayed as #.

I checked with excel properties. if the column property in excel is text and if your text size is more than 255 the total data is displayed as #.

How to rectify this?Any clues please

Thanks and Regards,

Rajesh

Former Member
Not what you were looking for? View more on this topic or Ask a question