导出WebPart是SharePoint的一个常用功能。可以快速实现在不同网页显示类似内容的WebPart。比如只是筛选条件不同时,可以先设置好一个WebPart,然后将其导出,之后建WebPart时只需简单几步就可以实现。
但是导出WebPart的功能不是每个WebPart默认有的,就连最常用的XSLT List View WebPart也默认禁用了该功能。怎么办?
在网上找到了一个解决办法《Exporting the XSLT List View Web Part in SharePoint 2010》,比较麻烦,下面简单介绍下如何恢复导出功能。
保存下面的文件Books1.webpart,注意下面高亮部分,需要根据WebPart显示的List做相应修改。
<?xml version="1.0" encoding="utf-8" ?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="ListUrl" type="string">Lists/Books</property>
<property name="ExportMode" type="exportmode">All</property>
</properties>
</data>
</webPart>
</webParts>
然后在添加WebPart时上传该WebPart,再添加到页面上。之后就可以看到导出功能了!
图 1插入WebPart时上载webpart文件
图 2在已导入的Web部件中选择刚刚上载的webpart
图 3已经可以导出WebPart啦!
其实有个更简单的办法,就是打开SharePoint Designer编辑页面,修改WebPart的ExportControlledProperties 为true。如下表所示。
<WebPartPages:ListViewWebPart runat="server" __MarkupType="xmlmarkup" WebPart="true" __WebPartId="{0213AD71-58FE-4E5F-AA4C-2A1B47B64FA2}" >
<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
<Title>Calendar</Title>
<FrameType>Default</FrameType>
<Description>Use the Calendar list to keep informed of upcoming meetings, deadlines, and other important events.</Description>
<IsIncluded>true</IsIncluded>
<PartOrder>1</PartOrder>
<FrameState>Normal</FrameState>
<Height />
<Width />
<AllowRemove>true</AllowRemove>
<AllowZoneChange>true</AllowZoneChange>
<AllowMinimize>true</AllowMinimize>
<AllowConnect>true</AllowConnect>
<AllowEdit>true</AllowEdit>
<AllowHide>true</AllowHide>
<IsVisible>true</IsVisible>
<DetailLink>/Lists/Calendar</DetailLink>
<HelpLink />
<HelpMode>Modeless</HelpMode>
<Dir>Default</Dir>
<PartImageSmall />
<MissingAssembly>无法导入此 Web 部件。</MissingAssembly>
<PartImageLarge>/_layouts/images/itevent.png</PartImageLarge>
<IsIncludedFilter />
<ExportControlledProperties>true</ExportControlledProperties>
<ConnectionID>00000000-0000-0000-0000-000000000000</ConnectionID>
<ID>g_a853f9dc_a07c_4ce0_815f_8022223ad333</ID>
<WebId xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">00000000-0000-0000-0000-000000000000</WebId>
<ListViewXml xmlns="http://schemas.microsoft.com/WebPart/v2/ListView"><View Name="{0213AD71-58FE-4E5F-AA4C-2A1B47B64FA2}" MobileView="TRUE" Type="CALENDAR" Hidden="TRUE" TabularView="FALSE" RecurrenceRowset="TRUE" DisplayName="" Url="/SitePages/Home.aspx" Level="1" BaseViewID="2" ContentTypeID="0x" MobileUrl="_layouts/mobile/viewdaily.aspx" ImageUrl="/_layouts/images/events.png"><Toolbar Type="Standard"/><ViewHeader/><ViewBody/><ViewFooter/><ViewEmpty/><ParameterBindings><ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)"/><ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)"/></ParameterBindings><ViewFields><FieldRef Name="EventDate"/><FieldRef Name="EndDate"/><FieldRef Name="fRecurrence"/><FieldRef Name="EventType"/><FieldRef Name="Attachments"/><FieldRef Name="WorkspaceLink"/><FieldRef Name="Title"/><FieldRef Name="Location"/><FieldRef Name="Description"/><FieldRef Name="Workspace"/><FieldRef Name="MasterSeriesItemID"/><FieldRef Name="fAllDayEvent"/></ViewFields><ViewData><FieldRef Name="Title" Type="CalendarMonthTitle"/><FieldRef Name="Title" Type="CalendarWeekTitle"/><FieldRef Name="Location" Type="CalendarWeekLocation"/><FieldRef Name="Title" Type="CalendarDayTitle"/><FieldRef Name="Location" Type="CalendarDayLocation"/></ViewData><Query><Where><DateRangesOverlap><FieldRef Name="EventDate"/><FieldRef Name="EndDate"/><FieldRef Name="RecurrenceID"/><Value Type="DateTime"><Month/></Value></DateRangesOverlap></Where></Query></View></ListViewXml>
<ListName xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">{118803C5-8E95-4219-B6DC-74F316814299}</ListName>
<ListId xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">118803c5-8e95-4219-b6dc-74f316814299</ListId>
<ViewFlag xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">8921097</ViewFlag>
<ViewFlags xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">Html Hidden RecurrenceRowset Calendar Mobile</ViewFlags>
<ViewContentTypeId xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">0x</ViewContentTypeId>
</WebPart>
</WebPartPages:ListViewWebPart>