Programmatically Export SharePoint List to Excel and Save it to a Document Library
Written By: Ivan Ivanov -- 8/9/2011 --
(7) comments --
Categories: Design, MOSS 2007, Programming and Customizations, WSS3
< Prev -
- Next >
| Become a paid author
I have a small online business selling consumer goods built on SharePoint. I
would like to export new requested items from a SharePoint list and send the
Excel file to my suppliers. I would also like my employees to be able to
manually choose which items to be exported to the Excel file...
The solution from the
fulfills these requirements, but there are some disadvantages:
- The file is stored on local user's computer/hard drive.
- The email to supplier has to be send manually.
- In the previous solution, first the status is changed and after that HttpContext.Current.Response is changed to display content in
Excel, so if a user presses "Cancel", the status will be changed, and there won't be a file.
- After the file is exported the user has to refresh or re-open the page to see that the status is changed.
The purpose of this article is to show how to build an automated export of SharePoint list items.
These would have different Excel files for each supplier, and a way to distinguish the
previously exported items from new items in the list.
The generated Excel files will be stored in a document library, and the status will be
updated. An automated email will be sent to the supplier.
First , we create a list as described on page 1 of the
Now we are going to write a new web part.
In order to make the web part we will use Visual Studio 2008.
On the Navigation Pane from the "File" menu, select "New Project". We will name this project as "WPStationeryDocLib".
Under "Project Types" select SharePoint, and under "Visual Studio installed Templates" select "WebPart Template", type the project name and press OK.
Next is to select the trust level for this project, and we chose Partial Trust.
For better visibility we rename our default name of the project folder from WebPart1 to WPStationeryExportToExcelDocLib
< Prev -
- Next >