How To Programmatically Export SharePoint List to Excel
Written By: Ivan Ivanov -- 7/12/2011 --
(7) comments --
Categories: 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...
To create this solution you should have a basic understanding about the following:
- Creating SharePoint lists, able to add and remove fields as
well as setting a predefine value to a field and work with list content types.
- You should have "full control" permissions in the target site
of the application.
- That you have Visual Studio 2008 installed on the machine you are developing this solution.
- You have a new blank site created for the application using
- You have permission to deploy a webpart in your environment.
The purpose of this article is to show you how you can build granular control
of the export functionality of SharePoint. With a single centralized list, you
want different Excel files for each of your suppliers, as well as to distinguish the exported items from the new items in the list.
So, we start by creating a
SharePoint list where you will have all requests as list items.
For the presentation we have added 3 fields:
- Product: is a choice field.
- Quantity: is a number field.
- Status: is a single line field, and is hidden in the new form by using the "hide" option in content types fields.
Users make the request by adding a new item to the list:
Now if you notice the "Status" field we have set this field with a default value of "New" and by that we know it is a new item which hasn't been exported.
Your employees need to be able to choose a set of all new requests, export them in an
Excel file and also the "Status" field must be updated upon exporting the items.
A few reasons to use the following method is that you can not do this with
out of the box "Export to Spreadsheet" functionality. And if you need to update the "Status" field of each item it
would be time consuming to do it one by one.
FFor this reason we are going to create a webpart that will:
< Prev -
- Next >
- Give you ability to choose which requests/items to be exported.
- Change the "Status" field value of the request/item upon exporting it to the
- And last, create the Excel file.