How to Use the SharePoint List Data Source

The SharePoint List data source uses CAML.  At this time, you will have to enter the queries manually if you need filtering.  A CAML wizard is in the works.

  1. In AutoTag, add a SharePoint List data source (not oledb).  

  2. Enter the URL of your site in the Server field, and enter the user name and password in the credentials box.

    1. The syntax of the connection string is URL=<WEB_URL>;USER=<USERNAME>;PASSWORD=<PASSWORD>;

  3. Create a forEach tag.

  4. Using the data tree, drag-drop a list or list field into the select= box.  Or if you use the data tree in the ribbon interface, you can just click the item.

  5. Create an out tag that uses the field from the forEach tag.

  6. Add the end forEach tag.

  7. Run the report.

The syntax of SharePoint List queries is like this:

 <listq>

    <list>

        <name>Windward Templates</name>

        <guid>{BCE573B8-9D1B-4220-993F-B40B6BA2F95B}</guid>

    </list>

    <Query />

    <ViewFields>

        <FieldRef Name="FileLeafRef" />

    </ViewFields>

</listq>

 <ViewFields> is optional, and so is <name>.  The rest is required.  <Query> is the actual CAML query.  If you want more sophisticated queries, you can type them in, or you can copy-paste them from the U2U CAML Query Builder.

 Programming with SharePoint List Data Source

 The following example shows how to use the SharePoint list data source in a program.  The SharePoint list data source is created via AdoDataSourceImpl using SPListConnection.

 public static void RunReport(string connStr, Stream template, Stream report)

{

    // get report gen

    Report rptGen = new ReportPdf(template, report);

 

    // process template

    rptGen.ProcessSetup();

 

    // load data

    IReportDataSource data = new AdoDataSourceImpl(typeof(SPListConnection), connStr);

 

    // process data

    rptGen.ProcessData(data, string.Empty);

 

    // finialize report

    rptGen.ProcessComplete();

 

    // flush report to stream

    report.Flush();

}

Using Macros

 SharePoint often returns list data with extra symbols attached that you want to get rid of.  That's where macros come in.  There are currently two macro functions available in Windward Reports version 9x - substring(), and indexOf().  Here is the syntax information for these macros.  For a complete list of available macro funcitons, see List of Equation Functions.

 Macro Syntax Notes

 Only works with <out> tags and must have an 'evaluate' attribute.

 Must begin with = to be recognized as an equation, to execute functions and do arithmetic.  With an = it is treated as a string.

 Function names are case insensitive.

 Example: <wr:out evaluate='=substring(${outVar}, indexOf(${outVar}, &quot;#&quot;)+1)'/>

 STRING subString(STRING target, INTEGER startIndex [, INTEGER endIndex])

   uses 0-index
 
NUMBER indexOf(STRING target, STRING strToSearch)
   returns 0-index number

Last edited Jun 18, 2012 at 3:55 PM by allisonl, version 2

Comments

No comments yet.