2

I'm using a DVWP in MOSS 2007 to display some data and using a jQuery library called table2CSV to be able to allow users to export the data on a button click. This is all working fine, the data is popped up in a window that will allow users to select all the contents and add it to Excel.

On the table2CSV page, they show an option to allow the data to be sent to a PHP server to return the data as an actual file.

I've got no knowledge of PHP, but I'd like to provide similar functionality. Using jQuery, what would my options be to make the SharePoint server send back an actual CSV file?

4 Answers 4

1

Could you use the jQuery SP Services lib to save the values to a CSV file to a library in SharePoint and then direct them to that file?

I've never used SP Services but I have heard great things about it.

0

There's really nothing built into SharePoint to handle this, you'd just need to pursue some custom asp.net development. You would need to write a custom webservice that would accept comma separated data in a post request, and then transform that data into a file. You could host that webservice in iis on the same machine as your sharepoint setup.

0

I would suggest exporting to excel and then have them save as CSV. Here is some client side code I wrote to override the "Export to Excel" button on the ribbon(just the Excel part). It takes xml, but might make a good starting point.

openExcel = function(xmlDoc){
        var Excel = new ActiveXObject("Excel.Application"),
            book,
            map,
            range,
            listObj;

        Excel.DisplayAlerts = false;
        Excel.Visible = true;
        book = Excel.Workbooks.Add();
        map = book.XMLMaps.Add(xmlDoc);
        range = book.ActiveSheet.Range("A1","I1").Select();
        listObj = book.ActiveSheet.ListObjects.Add();
        listObj.ListColumns(1).XPath.SetValue(map, "/Users/User/@PreferredName");
        listObj.ListColumns(2).XPath.SetValue(map, "/Users/User/@AccountName");
        listObj.ListColumns(3).XPath.SetValue(map, "/Users/User/@EmployeeNumber");
        listObj.ListColumns(4).XPath.SetValue(map, "/Users/User/@Title");
        listObj.ListColumns(5).XPath.SetValue(map, "/Users/User/@Office");
        listObj.ListColumns(6).XPath.SetValue(map, "/Users/User/@Manager");
        listObj.ListColumns(7).XPath.SetValue(map, "/Users/User/@ManagerAccountName");
        listObj.ListColumns(8).XPath.SetValue(map, "/Users/User/@ManagerTitle");
        listObj.ListColumns(9).XPath.SetValue(map, "/Users/User/@ManagerEmployeeNumber");
        listObj.ListColumns(1).Name = "Name";
        listObj.ListColumns(2).Name = "Account Name";
        listObj.ListColumns(3).Name = "Employee Number";
        listObj.ListColumns(4).Name = "Title";
        listObj.ListColumns(5).Name = "Office";
        listObj.ListColumns(6).Name = "Manager";
        listObj.ListColumns(7).Name = "Manager Account Name";
        listObj.ListColumns(8).Name = "Manager Title";
        listObj.LIstColumns(9).Name = "Manager Employee Number";
        book.XmlImportXml(xmlDoc, map,range);
    }
2
  • This is moss, ergo no ribbon Commented May 26, 2012 at 13:35
  • When I posted this, I was thinking of a button on the page. I just used the ribbon because it was there and already said "export to Excel". Commented May 26, 2012 at 15:29
0

Functionality abandoned and continuing with the status quo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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