I have completed my first sharepoint 2013 app (sharepoint hosted) where I'm using my own code to display list data etc rather than use any OTB pages/functionality.

The one feature I want to include from the OTB ribbon is the export to excel feature but I can't see any examples of this on MSDN, has anyone managed to do this via Javascript or JQuery?

Thanks,

S

For anyone interested this is how i did it!

Function to get my lists and views

function getLists() {
lists = web.get_lists();
context.load(lists, "Include(Id, Title, Hidden, ItemCount, Views)");
context.executeQueryAsync(onSuccess, onFail);
}

Function to get list and build link

function onSuccess() {

var listsEnum = lists.getEnumerator();
while (listsEnum.moveNext()) {
    var list = listsEnum.get_current();

    if (list.get_title() == "Name of list") {
        var title = list.get_title();
        var viewCollection = list.get_views();
        var viewInfo = 'Tasks list current views: \n\n';
        var viewEnumerator = viewCollection.getEnumerator();
        while (viewEnumerator.moveNext()) {
            var view = viewEnumerator.get_current();
            if (view.get_title() == "View-Title") {
                var viewGUID = view.get_id();
                //Add the export link
                $('#lnkExport').attr("href", "../_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=" + list.get_id().toString() + "&View=" + viewGUID + "&CacheControl=1");

            }

        }


    }


}


}
up vote 5 down vote accepted

I think this might help:

http://weblogs.asp.net/wkriebel/archive/2005/08/22/LinkToExportToSpreadsheet.aspx

Tested on SP2010

To replicate the funtionallity of "Export to Excel" (obtain the iqf file), all that needs to be done is replacing the place holders with your environment information in the following link:

http://[Server]/[Site]/([Subsite]/)_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=[ListGUID]&View=[ViewGUID]&CacheControl=1

Example:

http://example.net/dts/psronline/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=%7B1DBBD5FF%2DC452%2D412D%2D86F9%2DE3980F2F4EC4%7D&View=%7BF2E40BE2%2DB509%2D402E%2DBF7E%2DBC75907E9018%7D&CacheControl=1

Regards, David

  • Please do not post link-only answers. The answer will be of no help if the link breaks. Instead, add the important bits from the link to your answer (with a clearly visible source off-course) – Robert Lindgren Feb 11 '14 at 15:10
  • Sure, i will edit the response. – David Esteves Feb 11 '14 at 15:22
  • You think this dll is available in 2013? – Stephen Feb 11 '14 at 17:18
  • Yes, i don't have a SP 2013 environment available right now to test, but accordingly to this books.google.fr/… it is available. – David Esteves Feb 12 '14 at 9:19
  • Ok had some time to look at this and i don't think this will work as we don't know the List or view guid until we deploy. – Stephen Feb 12 '14 at 15:38

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.