Can anyone tell me that how can I export SharePoint search result for a particular keyword(which I passed in SharePoint search box web part) through REST API?
-
do you want the know about search query using REST API or the export functionality?– ThinkB4CodeJun 15, 2017 at 12:27
-
I want export to excel functionality.– trickytechieJun 15, 2017 at 12:32
1 Answer
There may be some JS API available which can do it in better way, but i prefer the old school way to export html tabular data into excel.
<html>
<body>
<table id="xyz">
<tr>
<td>ABC</td>
<td>DEF</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
</tr>
</table>
<a id="exportData" href="" download="text.xls">Export</a>
</body>
</html>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>
<script>
$(document).ready(function(){
var tableHTML = document.getElementById('xyz').outerHTML.replace(/ /g, '%20');
$('#exportData').prop('href', ('data:application/vnd.ms-excel, ' + tableHTML));
})
</script>
The only condition is, your data need to be in tabular format and when you are saying export to excel, it must be satisfying the condition.
-
My data is not in table format. I am using default view of SharePoint Search result to display. Oct 16, 2017 at 10:49