You need to sign in to do that
Don't have an account?
SHAIK MOHAMMAD YASEEN
Need to sort all the columns in excel sheet while downloading from vfpage
Hi All,
I am downloading an excel report from VFpage i am having four columns header1, header2, header3, header4, i am having sample data as below.
header1 header2 header3 header4
aaaa aaaaaa aaaaaaa aaaaaa
bbbb bbbbbb bbbbbbb bbbbbb
aaaa aaaaaa aaaaaaa aaaaaa
aaaa aaaaaa aaaaaab aaaaab
aaaa aaaaaa aaaaaab aaaaaa
aaaa aaaaab aaaaaab aaaaab
I need to sort as below. Please how can we achieve this. Please note that i am passing a map whcih holds the data. here is the format.
map<header1,List < obj>> where obj contains header2, header3, header4.
header1 header2 header3 header4
aaaa aaaaaa aaaaaaa aaaaaa
aaaa aaaaaa aaaaaaa aaaaaa
aaaa aaaaaa aaaaaab aaaaaa
aaaa aaaaaa aaaaaab aaaaab
aaaa aaaaab aaaaaab aaaaab
bbbb bbbbbb bbbbbbb bbbbbb
Please help me how to acheive this. Thanks
I am downloading an excel report from VFpage i am having four columns header1, header2, header3, header4, i am having sample data as below.
header1 header2 header3 header4
aaaa aaaaaa aaaaaaa aaaaaa
bbbb bbbbbb bbbbbbb bbbbbb
aaaa aaaaaa aaaaaaa aaaaaa
aaaa aaaaaa aaaaaab aaaaab
aaaa aaaaaa aaaaaab aaaaaa
aaaa aaaaab aaaaaab aaaaab
I need to sort as below. Please how can we achieve this. Please note that i am passing a map whcih holds the data. here is the format.
map<header1,List < obj>> where obj contains header2, header3, header4.
header1 header2 header3 header4
aaaa aaaaaa aaaaaaa aaaaaa
aaaa aaaaaa aaaaaaa aaaaaa
aaaa aaaaaa aaaaaab aaaaaa
aaaa aaaaaa aaaaaab aaaaab
aaaa aaaaab aaaaaab aaaaab
bbbb bbbbbb bbbbbbb bbbbbb
Please help me how to acheive this. Thanks
Can you try recursive Map collection to hold your data?
Something like,
Map<header1, Map<header2, map<header3, list<header4>>>>
I have use 2 level of recursive map collection.
When I get time, I can try this and confirm you back. Meanwhile, if you can, please try if your logic permits.
All Answers
I am just trying to understand, you are retrieving the data in a map collection where Header1 column is the Key data and other 3 columns are values in the form of an object.
If my understanding is correct, you can not have duplicate data in Header1 - Key data should be unique in Map collection.
If you have to sort the key data (header1),
- move the key data to the list and sort
eg
list<string> sortList = new List<String>();
sortList.addAll(Map.keySet());
sortList.sort(); //Header 1 will be sorted
for(String a: sortList)
{
System.debug( 'Header 1 ' + a + 'Other Headers' + Map.get(a)) ;
}
Thanks
Actually i am able to sort hader1 and header2, but unable to sort header3, header4, can you please help me with that
Can you try recursive Map collection to hold your data?
Something like,
Map<header1, Map<header2, map<header3, list<header4>>>>
I have use 2 level of recursive map collection.
When I get time, I can try this and confirm you back. Meanwhile, if you can, please try if your logic permits.