Uderc programming article aggregator sites

Export Custom List into Excel through custom Ribbon

Advertisement
Hi i have a requirement, in that i need to export custom list into EXCEL through custom Ribbon. For Example in my list, i have Col1, Col2, Col3. Col3 has multiple values (allow mutiple values) and when export this into excel all values in Col3 should
come as new rows and rest of the column values should duplicate. please helpout from this requirement.
List View
Col1   Col2      Col3
v1        v2    v31,v32,v33
Excel View
Col1  Col2  Col3
v1      v2      v31
v1      v2      v32
v1      v2      v33
Nihath
Advertisement
The best answer: Hello Nihath,
As per your description, you have to read each and every items in list with column value then only you can generate excel. There is direct way to export datatable to excel but in your case you will also need to iterate Col3 value to create new row in excel.
I would suggest to use CAML query to get all items then check Col3 value. If there are multiple value then add them as new datatable row and finally export full datatable to excel.
Here is link for CAML:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.listitemcollectionposition.aspx
Export datatable to excel:
http://stackoverflow.com/questions/12533626/export-datatable-to-excel
Finally add this feature in ribbon:
http://ankurmadaan.blogspot.in/2012/10/custom-ribbon-action-for-specific-list.html
Hope it could help
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help