Skip to Content
avatar image
Former Member

Excel Export - Funky Column Headers

I have this code which creates an XML representation of context data. However when the Spreadsheet opens the headers are all funky.

in Debug mode values are set fine:

entriesName = "People" but shows up in Excel as "/People"

entryName = "PeopleElement"

headerName = Correct header name (i.e., Name, WorkPhone,Email) but shows up in Excel as "/PeopleElement/Name","/PeopleElement/WorkPhone","/PeopleElement/Email".

Here is the code can someone help me figure out where/why these extra characters are being added?

String sXML;

String attributeName, headerName;

String entriesName = dataNode.getNodeInfo().getName();

String entryName = entriesName + "Element";

// trim given header texts, so that XML element names adhere to the rule 'no spaces contained'.

trimHeaderTexts(columnInfos);

sXML="<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n";

sXML=sXML"<"entriesName+">\n";

for (int i = 0; i < dataNode.size(); ++i)

{

IWDNodeElement dataNodeElement = dataNode.getElementAt(i);

sXML=sXML"<"entryName+">\n";

for (Iterator iter = columnInfos.keySet().iterator(); iter.hasNext();)

{

attributeName = (String) iter.next();

headerName = (String) columnInfos.get(attributeName);

sXML=sXML+"<";

sXML=sXML+headerName;

sXML=sXML+">";

sXML=sXML+"<![CDATA[";

sXML=sXML+dataNodeElement.getAttributeValue(attributeName);

sXML=sXML+"]]>";

sXML=sXML+"</";

sXML=sXML+headerName;

sXML=sXML+">\n";

}

sXML=sXML"</"entryName+">\n";

}

sXML=sXML"</"entriesName+">\n";

return sXML;

Also I would like the columns to display in a different order than they do (they are displaying in the order of the context element but I would like them to display in a more logical order. I set up this mapping but it doesn't seem to change the order it just seems to set which elements from the selected node to display.

private Map getPersonColumnInfo()

{

Map columnInfoMap = new LinkedHashMap();

columnInfoMap.put(IPrivatePeopleFinderResultsView.IPeopleElement.NAME,"Name");

columnInfoMap.put(IPrivatePeopleFinderResultsView.IPeopleElement.WORK__PHONE, "Work Phone");

columnInfoMap.put(IPrivatePeopleFinderResultsView.IPeopleElement.EMAIL, "Email");

return columnInfoMap;

}

Edited by: TA on Aug 13, 2008 5:59 PM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 13, 2008 at 04:47 PM

    Hi TA,

    Kindly look at the following links for more clarification

    - https://www.sdn.sap.com/irj/sdn/wiki?path=/x/0mq

    - Tutorials & Samples for Web Dynpro Java

    The above link has ready to use code which can be used for download to excel , or you can use jexcel.api which is also a freeware and does not download the data as an xml string.

    Regards

    Pankaj Prasoon

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 14, 2008 at 04:20 AM

    Hi

    Try this link

    problem-sending-data-to-excel-sheet

    Regards

    Vinod V

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      This is the XML string that the code generates:

      "<?xml version='1.0' encoding='UTF-8' standalone='n'>

      <People>

      <PeopleElement>

      <Name><![CDATA[Terri]]></Name>

      <a href="http://Terri.hotmail.com" target="_blank">Terri.hotmail.com</a>

      <Phone><![CDATA[4581]]></Phone>

      </PeopleElement>

      <PeopleElement>

      <Name><![CDATA[Bob]]></Name>

      <a href="http://Bob.hotmail.com" target="_blank">Bob.hotmail.com</a>

      <Phone><![CDATA[3344]]></Phone>

      </PeopleElement>

      </People>"

      I thought this was coming out in the wrong order but it is not - The XML string is generated correctly it is upon conversion to excel it seems to get messed up.

      Edited by: TA on Aug 14, 2008 8:29 PM

      Edited by: TA on Aug 20, 2008 10:50 PM

      Edited by: TA on Aug 20, 2008 10:54 PM

  • avatar image
    Former Member
    Sep 11, 2008 at 12:32 PM

    Ended up using the advance excel tutorial mixed with the binary cache tutorial for a good solution

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      I am getting Lost document summary information when trying to open the excel sheet

      Please help me in resolving this

      Thanks

      Bala Duvvuri