Class SharePointDataProvider
- Namespace
- combit.Reporting.DataProviders
- Assembly
- combit.ListLabel31.CrossPlatform.dll
Provides a data provider implementation for SharePoint data sources using REST API.
public sealed class SharePointDataProvider : IDataProvider, ISupportsLogger
- Inheritance
-
SharePointDataProvider
- Implements
- Inherited Members
Examples
The following example demonstrates how to use the SharePointDataProvider to export a report to PDF:
// Example 1: Connect to SharePoint Online (modern authentication)
SharePointDataProvider provider = new SharePointDataProvider(
"https://contoso.sharepoint.com/sites/mysite");
// Note: For SharePoint Online, you typically need to use app-only authentication
// or other modern auth methods through custom headers
// Create a ListLabel reporting engine instance and assign the provider as the data source.
using ListLabel listLabel = new ListLabel();
listLabel.DataSource = provider;
// Configure export settings to generate a PDF.
ExportConfiguration exportConfiguration = new ExportConfiguration(LlExportTarget.Pdf, exportFilePath, projectFilePath);
exportConfiguration.ShowResult = true;
// Export the report to PDF.
listLabel.Export(exportConfiguration);
// Example 2: Connect to on-premises SharePoint with credentials
SharePointDataProvider onPremProvider = new SharePointDataProvider(
"https://sharepoint.company.local/sites/hr",
"username",
"password",
"DOMAIN");
// Example 3: Configure connection timeout for slow networks
SharePointDataProvider slowProvider = new SharePointDataProvider(
"https://sharepoint.company.local/sites/projects");
slowProvider.ConnectionTimeout = 60; // 60 seconds timeout
// Example 4: Connect without domain (workgroup authentication)
SharePointDataProvider workgroupProvider = new SharePointDataProvider(
"https://sharepoint.local",
"localuser",
"password",
"");
// Example 5: Use with custom authentication headers (e.g., Bearer token)
SharePointDataProvider tokenProvider = new SharePointDataProvider(
"https://contoso.sharepoint.com/sites/mysite");
// Note: Custom header configuration would be done through the underlying HTTP client
// This typically requires extending the provider or using SharePoint app authentication
Remarks
The SharePointDataProvider class implements IDataProvider and ISupportsLogger to enable connectivity to SharePoint lists and libraries through SharePoint's REST API. The provider automatically introspects SharePoint list schemas by querying the _api/lists endpoint, discovering list metadata including field definitions, data types, and list properties. It filters out hidden system lists and only includes lists with attachment support enabled by default. The provider supports both SharePoint Online and SharePoint Server (on-premises) deployments. Authentication can be configured using network credentials (username, password, domain) for on-premises SharePoint or modern authentication for SharePoint Online. Custom HTTP headers can be added for additional authentication scenarios. The connection timeout is configurable for slower network connections or large list schemas. List data is retrieved in XML format and parsed to extract schema information. The provider creates a table for each accessible list, enabling reporting on SharePoint list data directly from List & Label. This is useful for creating reports from SharePoint lists, document libraries with metadata, or custom lists without writing custom code.
Constructors
SharePointDataProvider(string)
Initializes a new instance of the SharePointDataProvider class with the specified SharePoint URL.
public SharePointDataProvider(string url)
Parameters
urlstringThe URL of the SharePoint site.
SharePointDataProvider(string, string, string, string)
Initializes a new instance of the SharePointDataProvider class with the specified connection details.
public SharePointDataProvider(string url, string username, string password, string domain)
Parameters
urlstringThe URL of the SharePoint site.
usernamestringThe user name for authentication.
passwordstringThe password for authentication.
domainstringThe domain for authentication.
Properties
ConnectionTimeout
Gets or sets the connection timeout (in seconds) used for REST requests.
public int ConnectionTimeout { get; set; }
Property Value
Url
Gets the base URL of the SharePoint site.
public string Url { get; }