In this article, we will learn How to Export Data View To Excel In SharePoint 2013 / 2016.
In SharePoint 2013 and 2016, I have created a Data View Web Part with an external database connection as a data source using SharePoint Designer.
But When browsing the page, I couldn’t find the SharePoint List Ribbon, also there is no option to export the data view to Excel as shown below.
You might also like to read Data View disabled in SharePoint Designer 2013
Cause
Unfortunately, there is no an OOTB option to export Data View with an external database connection in SharePoint.
As a workaround to Export Data View To Excel In SharePoint, you have the below two options:
- Use Internet Explorer.
- Use JQuery custom code.
You can easily use Internet Explorer to Export the Data View to Excel by doing the following:
Steps
- Open SharePoint Designer, Create a new web part page.
- Add a new Data View Web Part from the database connection as a data source.
- From the above ribbon, Click Paging > Display All Items.
- Save and Browse the page in Internet Explorer.
- Right-click on the data view > Select Export to Microsoft Excel.
Beside the above option, you can use table2excel JQuery to export the Data view web part to Excel, by doing the following:
Steps
- Open SharePoint Designer, Create a new web part page.
- Add a new Data View Web Part from the database connection as a data source.
In case of the Date View button is grayed out in SharePoint Designer check Data View is disabled in SharePoint Designer 2013.
- From the above ribbon, Click Paging > Display All Items.
Note: In my case, I am working on Export Data View to Excel With Paging Option.
- Set an ID for the Dataview Table that holds the Fields as shown below:
- Above the table add an Export button as shown below:
"input id="btnExport" type="button" value="Export DV to Excel"
- Go Up, below the “meta” tag and add the below script.
- Note: Don’t forget to change the table ID with your Table ID at
$("#MQassas").table2excel({
- Note: Don’t forget to change the table ID with your Table ID at
- Browse the page again > Click on the Export button, the data view should be now exported to excel as shown below:
By the way, you can use the above script directly in Script Editor Web Part, but any new change in the page via SharePoint designer will reset any customization (Script Editor Web Part) added via the browser.
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.rawgit.com/rainabba/jquery-table2excel/1.1.0/dist/jquery.table2excel.min.js"></script>
<script>
$(document).ready(function() {
$("#btnExport").click(function(){
$("#MQassas").table2excel({ exclude: ".noExl", name: "Export DataView to Excel", filename: "myFileName" + new Date().toISOString().replace(/[\-\:\.]/g, ""), fileext: ".xls", exclude_img: true, exclude_links: true, exclude_inputs: true }); }); });
</script>
Conclusion
The data view web part doesn’t have the full functionality ribbon like the Export to Excel feature. so here, we have provided two workarounds to can export data view to excel in SharePoint.
Applied To
- SharePoint 2016.
- SharePoint 2013.