Monday, April 6, 2009

Adding Export To Spreadsheet to a Picture Library

Sometimes customers want to have all the functionality of a Picture Library but also that of a Document Library. Specifically the option to have a Excel Report on a bunch of images. Now that sounds simple. Just Expor to Spreadsheet. Well guess what. Some clever dude took that action out of the menu. Why? No idea. Because it does not work? Bollocks. Of course it works. below is how you can get it back again. Simply add a Custom Action to your feature elements and deploy. Happy Exporting.the trick is in dynamically creating the iqy string.

<CustomAction Id="UserInterfaceCustomActions.DocLibActionsToolbar"
RegistrationType="List"
RegistrationId="109"
GroupId="ActionsMenu"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1000"
Title="Export To Spreadsheet"
ImageUrl="/_layouts/images/MenuSpreadsheet.gif">
<UrlAction
Url="javascript:EnsureSSImporter();javaScript:ExportList('{SiteUrl}\u002f_vti_bin\u002fowssvr.dll?CS=65001\u0026Using=_layouts\u002fquery.iqy\u0026List={ListId}\u0026RootFolder=' + ctx.listUrlDir + '\u0026CacheControl=1')" />
</CustomAction>

10 comments:

kk said...

can you please let me know if there is way we can make it dynamic for view too
right now the query is giving the default view

Unknown said...

try looking at the querystring of the export option of other libraries. that is where I figured the syntax out from.

Unknown said...

Effectively you need to add the view querystring to the url by adding
\u0026View=' + ctx.view + '

kk said...

Thanks a lot,you saved my day,still there is an issue with the rootfolder its not filter item by the folder ur in

kk said...

can you please help me in finding the rightfunction to return exact rootfolder instead of the listurl directory,i tried in vain i am novice to this

Unknown said...

ouch. I've had problems with folders in the past. Not sure what the setting is for that.

Unknown said...

Hey this might be exactly what im looking for, but im a novice. will this show for a Libraries on a site or just picture libraries. If so what is the line of code specifying that. also if this is for all libraries does that mean if i create a doc library it will technically have to items for exporting?

Unknown said...

Exporting to Spreadsheets has always been possible from document libraries. You can find it on the actions menu.
Another way to get to the spreadsheet export option is to open the list/library in Datasheet view and then open the toolpane.

But then you don't get the Datasheet view on Picture Libraries either. Grrr.

Unknown said...

Thanks, what I wanted to see was if it wasnt going to double up on the document libraries (i.e. on top of the traditional export option my option will show up). Is there a way to say only show up on a particular list?

Unknown said...

Saldy you can not target features at individual lists but rather at sites or in some cases list types. You could create a derived list with the feature enabled on it and add it to your list template gallery.