Some webparts can’t be exported by the UI to get the XML representation of it.
Listview webparts are one of them. To get the XML anyway there are three options to do so:
- Use javascript from the Export option
- Use the exportwp page directly
- Enable the Export functionality
Javascript
For listview webparts the Export option is present, although not visible. Inline style ‘display:none;’ prevents showing the Export option, but it can be found using the browser’s developer tools.
The easiest way to find it is to search for ‘MSOMenu_Export’ in the HTML of the page.
To easily export the XML representation of the webpart copy the call in the onmenuclick javascript. (include javascript: before the call)
Open the webpart menu as if you were going to export it and paste the javascript into the URL section of the browser and hit enter. You will be prompted to save or open the webpart file.
Exportwp page
Another option is to use the exportwp.aspx page, located in the _vti_bin folder, directly. Directly, because the javascript above also uses this page, take a closer look at the code there.
Parameters are the page url and guidstring, which is the guid of the webpart. The javascript gathers all the data for us, but we can also format the call by ourselves.
Get the webpartid from the developer tools:
And format the url:
<url of the web where the page is stored>/_vti_bin/exportwp.aspx?pageurl=<absolute url of the page where the webpart is placed on>&guidstring=<id of the webpart>
Enable Export
The last and faremost the easiest way is to enable the Export functionality of the webpart. Not in the webpart properties, but in the developer tool of the browser:
Set this property to true and the Export menu option is available and working.
Summary
There are several ways to export a webpart when the Export option isn’t available in the menu of the webpart. To enable this is the faremost easiest option when it is available. Otherwise the user of the exportwp page is a close second.