in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Ton Stegeman [MVP] weblog

Export user information to Excel using "Export to spreadsheet" in SharePoint 2007

In mosts lists in SharePoint the Actions menu has an option “Export to spreadsheet”. Using this option you can easily export the contents of the current view to an Excel spreadsheet.I got the question why this link is not available in the User Information list. This is the list that you can access from “People and Groups” – “All People”.

     Userinfo1

The  Actions menu on this page does not have the option “Export to spreadsheet”. You can still export the content of this list by using the url below:

http://[SITEURL]/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=[LISTID]&View=[VIEWID]&CacheControl=1

In this url, you will need to change these 3 options:

  • [SITEURL] – the url of your top level site
  • [LISTID] – The Guid of the User Information List
  • [VIEWID] – The Guid of the view that you want to export.

The easiest way to get the [LISTID] and [VIEWID] is to select “List Settings” in the “Settings” menu from the screenshot above. First you need to configure a view to have the columns and filters etc. to get the users that you want to export. This is exactly the same process as in any other SharePoint list. While you are configuring your view, the address bar of your browser contains the IDs that you will need:

     Userinfo2

Copy the List and View querystring parameters from this url to the url mentioned above.

Then copy the full url with all correct values in your browser address bar, and the user information will show up in Excel:

     Userinfo3

In my case the full url looks like this:

http://office2007/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=%7B299130F0%2D2E0B%2D4A02%2D8AF0%2D43BA54C79B28%7D&View=%7B45A446EB%2DCFA4%2D4DEE%2D8616%2D5B43AFBC7B31%7D&CacheControl=1

At this point I thought, I might as well create a feature that add this action as an item to the Actions menu for the list. So I created a feature file and an elements file and added a “CustomAction” element. I set the RegistrationType to List and the RegistrationId to 112, which is the list template type id for this list. After registering and activating the feature, my new menu item did not show up in the actions menu. It looks like this list looks like a normal SharePoint list, but it is not 100%. Although the first screenshot shows an Actions and Settings menu, these items seem not to be created as in all the other lists. If you go to the List Settings of the list, select one of the views and click OK, you will see this screenshot:

     Userinfo4

It looks like the normal Toolbar was removed from the list schema and the menus are added in another way. The difference is that in the screenshot above, we are in the page /_catalogs/users/simple.aspx and in the first screenshot we are on page /_layouts/people.aspx. This people.aspx page contains the menu items for our actions menu. Because it is not recommended to change the SharePoint pages directly, I gave up trying to add my item to the Actions menu.

Instead I created an item in the site settings page. In the “Users and Permissions” sections users now have an opion “Export User Information”:

   Userinfo5

The XML file for my feature:

<Feature 
  xmlns="http://schemas.microsoft.com/sharepoint/"
  Id="E9189036-3847-4D63-8A13-483FDAE44973"
  Title="Export User Information to spreadsheet"
  Description="Menu item to export user information to a spreadsheet."
  Scope="Site">
  <ElementManifests>
    <ElementManifest Location="elements.xml" />
  </ElementManifests>
</Feature>

And the XML file for the elements.xml file: Please note that you will need to replace [LISTID] and [VIEWID] with the appropriate values (see above)

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="ADD173BC-C9B2-48EE-A1AF-3529C2338C06"
      GroupId="UsersAndPermissions"
      Location="Microsoft.SharePoint.SiteSettings"
      Sequence="100"
    Title="Export User Information"
      Description="Export User Information to spreadsheet.">
    <UrlAction Url="/_vti_bin/owssvr.dll?CS=109&amp;Using=_layouts/query.iqy&amp;List=[LISTID]&amp;View=[VIEWID]&amp;CacheControl=1"/>
  </CustomAction>
</Elements>

After installing and activating the feature at the site collection features, the menu option is available.

Comments

 

Crossman said:

Very nice and usefull :) thanks :)

October 8, 2007 3:47 AM
 

Oscar Medina's Blog said:

Another way to retrieve SharePoint List Data - Use built in functionality!

December 11, 2007 10:44 AM
 

MOSS is my middle name said:

Genious! Thanks!

January 2, 2008 8:40 AM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts