on 02-20-2007 1:21 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hallo Ashwin,
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.