Skip to main content

Posts

Showing posts from November, 2014

Create Excel from SharePoint List Data and Send by email

During my daily task allocation I came across a task in which I was supposed to create excel from SharePoint list and then send the created excel via email. The procedure was to be repeated daily. I used timer job to repeat task on daily basis. As I was unaware of the column that may exist in SharePoint list so I thought of using SharePoint views (i.e., AllItems ) to get the list of fields. Also this facilitated my code to be dynamic enough to be replaces with custom created views. Add a new class file to project: Right click project > Add > class Name class file: ListToExcelGenerator namespace xxx {     /// <summary>     /// Class to create Excel from Sharepoint List     /// </summary>     class ListToExcelGenerator     {         /// <summary>         /// Sets file path as well file name.         /// </summary>         /// <param name="url">url of the web application/rootsite</param>         public void ListToExce