Skip to Content
avatar image
Former Member

Issue of export to excel

Hi All

I got a requirement where i have to export the table to the excel 2003 i had done that. but not getting order of the fields as per the table, using the the following code

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

IWDNodeElement dataNodeElement = dataNode.getElementAt(i);

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

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

attributeName = (String) iter.next();

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

x

.append("<")

.append(headerName)

.append(">")

.append(dataNodeElement.getAttributeValue(attributeName))

.append("</")

.append(headerName)

.append(">\n");

}</i>

can any one give me a clue how to get the same order as in table or as iam passing to the excel from webdynpro code..

Thanks & Regards

Ashwin

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Feb 21, 2007 at 08:34 AM

    Hey,

    This is the simple instead of mar parameter u can chage the LinkedHashMap.

    Then you can get the same order and u need to give the order when u give your value attributes at your method in TableApp.

    wdthis.wdGetAPPInterface.ExpoertExcel(wdcontext.node<name>(),getValues());

    the Imple of this method

    private LinkedHashMap getValues()

    {

    // you can give ur value attrbute what ever order do u need.

    return LikedhshMap;

    }

    Any probs post ur issues.

    Thanks,

    Lohi.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 21, 2007 at 02:36 AM

    Hi Ashwin,

    by default you will get order of the feilds same as the order of attributes of the dataNode but not as in table.if you want the order same as table, you have to check and pass fields manually.

    regards,

    Siva

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Ashwin,

      Probabaly this <a href="/people/subramanian.venkateswaran2/blog/2006/08/16/exporting-table-data-to-ms-excel-sheetenhanced-web-dynpro-binary-cache Webdynpro Table to Excel</a> should help you in resolving the problem.

      - Nagarajan.

  • Feb 21, 2007 at 08:44 AM

    Hi,

    I was facing the same problem.

    The reason is that , the order of the headers in Excel is, in the ascending order of the value attributes' name.

    Eg:...if your value attribute names are: ctx_va_name, ctx_va_salary and ctx_va_age, then by default, in excel, the headers will be in the following order:

    ctx_va_age, ctx_va_name, ctx_va_salary .

    So, if you want the name to appear first, then the salary and then age,

    then rename the vaule attributes as:

    Actx_va_name, Bctx_va_salary, Cctx_va_age.

    This has solved the problem, so i am sure it will solve yours too

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 13, 2007 at 12:54 PM

    Hallo Ashwin,

    you refer to my Excel Export tutorial on SDN: Exporting" target="_blank">https://wiki.sdn.sap.com/wiki/x/0mQ">Exporting Table Data Using On-Demand Streams - SAP NetWeaver 7.0:

    use <b>LinkedHashMap</b> instead of <i>HashMap</i>:

      private Map getProductColumnInfos() {
        Map columnInfosMap = new LinkedHashMap();
        columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.QUANTITY, "Quantity");
        columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.ARTICLE, "Article");
        columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.COLOR, "Color");
        columnInfosMap.put(IPrivateTableCompBasketView.IProductsElement.PRICE, "Price in EURO");
        columnInfosMap.put(
          IPrivateTableCompBasketView.IProductsElement.TOTAL__PER__ARTICLE,
          "Total Per Article In Euro");
        return columnInfosMap;
      }

    This keeps the order of key-displaytext-pairs passed by the client (table component) to the service (excel export component) stable.

    Regards, Bertram

    Add comment
    10|10000 characters needed characters exceeded