cancel
Showing results for 
Search instead for 
Did you mean: 

Specifying the order of column in Excel file

Former Member
0 Kudos

How to specify the order of the columns in excel when data is exported from a table to excel.For eg. I have 2 columns in a table i.e. Base Location and Employee Number.When I export this data to the excel file the columns are displayed according to the alphabetical order i.e. Base Location first and then Employee Number. Whereas I want Employee Number column to be displayed first and then the Base Location column.

Can anyone help me on this?

Accepted Solutions (0)

Answers (1)

Answers (1)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Sowmya,

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

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