I'm currently doing a little proof of concept, but I'm either failing to understand something or I did something wrong.
Here's the code snippet:
class Program
{
static void Main(string[] args)
{
Telerik.Reporting.Report report = new Telerik.Reporting.Report();
string selectCommand = @"SELECT * FROM Test.dbo.TestTable"; //Assume that the query works in SQL
string connectionString = @"Data Source=.\DEVSQL;Initial Catalog=Test;Integrated Security=True;Persist Security Info=True;";
Telerik.Reporting.SqlDataSource sqlDataSource = new Telerik.Reporting.SqlDataSource(connectionString, selectCommand);
report.DataSource = sqlDataSource;
ExportToPDF(report);
}
public static void ExportToPDF(Telerik.Reporting.Report reportToExport)
{
ReportProcessor reportProcessor = new ReportProcessor();
Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument = reportToExport;
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);
string fileName = result.DocumentName + "." + result.Extension;
string path = System.IO.Path.GetTempPath();
string filePath = System.IO.Path.Combine(path, fileName);
using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
}
}
After executing this I get an empty PDF, even though the table has several rows.