Skip to Content
avatar image
Former Member

Table to Excel - correct order

Hi,

I want to display the contents of a table in excel format.

I have followed the below link for the same.

/people/sap.user72/blog/2006/05/04/enhancing-tables-in-webdynpro-java-150-custom-built-table-utilities

The excel is generated with all contents, but the order in which the columns appear is not same as the order in which i add them to the Arraylist. It actually takes the order of the contex attributes(of the table node).

Is there a way to change the order of the columns?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Oct 10, 2006 at 10:55 AM

    Shikha,

    Please post your code where you creating ArrayList of column info objects.

    VS

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      Below is the code:

      public java.util.ArrayList getColumns( )

      {

      //@@begin getColumns()

      ArrayList columnsList = new ArrayList();

      columnsList.add(IPublicDashboardCust.IDashboardViewElement.CRID);

      columnsList.add(IPublicDashboardCust.IDashboardViewElement.TYPENAME);

      columnsList.add(IPublicDashboardCust.IDashboardViewElement.STATNAME);

      columnsList.add(IPublicDashboardCust.IDashboardViewElement.CRDATE);

      columnsList.add(IPublicDashboardCust.IDashboardViewElement.DELIBUCKAPPL);

      columnsList.add(IPublicDashboardCust.IDashboardViewElement.DELIPROJAPPL);

      columnsList.add(IPublicDashboardCust.IDashboardViewElement.RECVBUCKAPPL);

      columnsList.add(IPublicDashboardCust.IDashboardViewElement.RECVPROJAPPL);

      return columnsList;

      //@@end

      }

  • Aug 13, 2007 at 01:01 PM

    Hallo Shikha,

    I 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