4

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");

            }

        }


    }


}


}

1 Answer 1

6

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

9
  • 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) Feb 11, 2014 at 15:10
  • Sure, i will edit the response. Feb 11, 2014 at 15:22
  • You think this dll is available in 2013?
    – Stephen
    Feb 11, 2014 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. Feb 12, 2014 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, 2014 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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