首页 文章

Reporting Services,从任何Sharepoint列表中获取数据

提问于
浏览
3

我正在尝试根据Sharepoint(2010)列表构建SSRS(2008R2)报告 . 主要问题是运行报告的List必须是报告参数 . 我知道列表结构是什么,但sharepoint站点可以包含多个具有此结构的列表实例,并且在运行报告时,用户必须选择列表名称 . 此外,该报告还有两个日期参数MinDateTime和MaxDateTime,并且仅选择具有这两个参数的记录 .

据我所知,构建报告至少有两种方法:

  • 使用Sharepoint List Data Source并在CAML中编写数据集查询,在DataSource中指定站点,让SSRS处理其余的详细信息 . 这种情况下的问题是我无法将ListName指定为报表参数 . DataSet查询如下所示:
<pre>
   <RSSharePointList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <ListName>BusinessList1</ListName>
          <ViewFields>
            <FieldRef Name="Title" />
            <FieldRef Name="BusinessUnit" />
            <FieldRef Name="ScanDateTime" />
          </ViewFields>
          <Query>
            <Where>
              <And>
                <Geq>
                  <FieldRef Name="ScanDateTime" />
                  <Value Type="DateTime">
                    <Parameter Name="MinScanDateTime" />
                  </Value>
                </Geq>
                <Leq>
                  <FieldRef Name="ScanDateTime" />
                  <Value Type="DateTime">
                    <Parameter Name="MaxScanDateTime" />
                  </Value>
                </Leq>
              </And>
            </Where>
          </Query>
        </RSSharePointList>
  • 使用XML数据源并以肥皂可读的XML编写数据集查询,直接访问/_vti_bin/lists.asmx webservice . 查询应该类似于此(包括列表名称作为参数) . 但是,我无法使用Date参数使其工作 . 它们应该添加到哪里?
<pre>  
   <Query>
      <SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
   <Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
      <Parameters>
         <Parameter Name="listName">
            <DefaultValue>BusinessList1</DefaultValue>
         </Parameter>
         <Parameter Name="viewFields">         
              <ViewFields>
                <FieldRef Name="Title" />
                <FieldRef Name="BusinessUnit" />
                <FieldRef Name="ScanDateTime" />
             </ViewFields>
         </Parameter>
      </Parameters>
   </Method>
   <ElementPath IgnoreNamespaces="True">*</ElementPath>
</Query>

任何方向都会很棒 . 谢谢,

1 回答

  • 1

    您可以使用选项1,将查询编写为表达式 . 使用中间的参数构建一个长字符串 . 您需要单独的查询来向参数提供BusinessLists列表 .

    表达式如下所示:

    ="<pre>
       <RSSharePointList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <ListName>"
    
    & Parameters!BusinessList.value & 
    
    "</ListName>
              <ViewFields>
                <FieldRef Name="Title" />
                <FieldRef Name="BusinessUnit" />
                <FieldRef Name="ScanDateTime" />
              </ViewFields>
              <Query>
                <Where>
                  <And>
                    <Geq>
                      <FieldRef Name="ScanDateTime" />
                      <Value Type="DateTime">
                        <Parameter Name="MinScanDateTime" />
                      </Value>
                    </Geq>
                    <Leq>
                      <FieldRef Name="ScanDateTime" />
                      <Value Type="DateTime">
                        <Parameter Name="MaxScanDateTime" />
                      </Value>
                    </Leq>
                  </And>
                </Where>
              </Query>
            </RSSharePointList>"
    

    [编辑]:我使用sharepoint列表连接类型创建测试报告并且不添加它 . 看看这个MS link on the basics .

    它指出你不需要指定要返回的字段,所以一个非常基本的查询表达式看起来像这样(添加了我的填充参数):

    ="<RSSharePointList xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""><ListName>" & Parameters!List.Value & "</ListName></RSSharePointList>"
    

    在我上面的原始示例中,我没有提到您需要通过将它们加倍来转义XML中的双引号 . 我测试过这个并且效果很好 .

相关问题