static void Main(string[] args) { // Initialize the engine Report.Init(); // Open template file and create output file FileStream template = File.OpenRead("../../../Samples/Microsoft SQL Server - Template.docx"); FileStream output = File.Create("../../../Samples/SQL Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); string strConn = "Data Source=mssql.windward.net;Initial Catalog=Northwind;User ID=demo;Password=demo"; // SQL data source using (AdoDataSourceImpl adoDatasource = new AdoDataSourceImpl("System.Data.SqlClient", strConn)) { //run the report process myReport.ProcessSetup(); //the second parameter is the name of the data source myReport.ProcessData(adoDatasource, "MSSQL"); myReport.ProcessComplete(); } //close out of our template file and output output.Close(); template.Close(); // Open the finished report string fullPath = Path.GetFullPath("../../../Samples/SQL Report.pdf"); System.Diagnostics.Process.Start(fullPath); }
public void OracleReport() { // Initialize the engine Report.Init(); // Open template file and create output file FileStream template = File.OpenRead("../../../Samples/Oracle - Template.docx"); FileStream output = File.Create("../../../Samples/Oracle Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); // Oracle data source string strConn = "Data Source=oracle.windward.net:1521;Persist Security Info=True;User ID=HR;Password=HR;"; IReportDataSource data = new AdoDataSourceImpl("Oracle.DataAccess.Client", strConn); //run the report process myReport.ProcessSetup(); //the second parameter is the name of the data source myReport.ProcessData(data, "ORACLE"); myReport.ProcessComplete(); //close out of our template file and output output.Close(); template.Close(); string fullPath = Path.GetFullPath("../../../Samples/Oracle Report.pdf"); System.Diagnostics.Process.Start(fullPath); }
public void DB2Report() { // Initialize the engine Report.Init(); // Open template file and create output file FileStream template = File.OpenRead("../../../Samples/DB2 - Templates.xlsx"); FileStream output = File.Create("../../../Samples/DB2 Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); // DB2 data source string strConn = "server=db2.windward.net;database=Sample;User ID=demo;Password=demo;"; IReportDataSource data = new AdoDataSourceImpl("IBM.Data.DB2", strConn); //run the report process myReport.ProcessSetup(); //the second parameter is the name of the data source myReport.ProcessData(data, "DB2");; myReport.ProcessComplete(); //close out of our template file and output output.Close(); template.Close(); string fullPath = Path.GetFullPath("../../../Samples/DB2 Report.pdf"); System.Diagnostics.Process.Start(fullPath); }
protected void Page_Load(object sender, EventArgs e) { string basePath = Request.PhysicalApplicationPath + "\\"; // Initialize the engine. License and configuration settings in web.config. Report.Init(); // Open template file FileStream template = File.OpenRead(basePath + "DB2 - Templates.xlsx"); // Create report process Report myReport = new ReportPdf(template); // SQL data source string strConn = "server=db2.windward.net;database=Sample;User ID=demo;Password=demo;"; IReportDataSource data = new AdoDataSourceImpl("IBM.Data.DB2", strConn); // Run the report process myReport.ProcessSetup(); //the second parameter is the name of the data source myReport.ProcessData(data, "DB2"); myReport.ProcessComplete(); // Close out of our template file template.Close(); // Opens the finished report //Response.ContentType = "application/pdf"; // this would have the pdf open in the browser (disable content-disposition:attachment if you want this) Response.ContentType = "application/save"; // this is used with content-disposition to give the proper name of the file Response.AppendHeader("content-disposition", "attachment; filename=\"Report.pdf\""); Response.BinaryWrite(((MemoryStream)myReport.GetReport()).ToArray()); Response.End(); // Must be called for MS Office documents }
public void MySQLReport() { // Initialize the engine Report.Init(); // Open template file and create output file FileStream template = File.OpenRead("../../../Samples/MySQL - Template.docx"); FileStream output = File.Create("../../../Samples/MySQL Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); // MySQL data source string strConn = "server=mysql.windward.net;database=sakila;user id=test;password=test;"; IReportDataSource data = new AdoDataSourceImpl("MySql.Data.MySqlClient", strConn); //run the report process myReport.ProcessSetup(); //the second parameter is the name of the data source myReport.ProcessData(data, "MYSQL"); myReport.ProcessComplete(); //close out of our template file and output output.Close(); template.Close(); string fullPath = Path.GetFullPath("../../../Samples/MySQL Report.pdf"); System.Diagnostics.Process.Start(fullPath); }
private static void RunReport(string templateFilename, string outputFilename, Dictionary <string, object> adHocVariables) { // get the report ready to run. using (Stream template = new FileStream(templateFilename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (Stream output = new FileStream(outputFilename, FileMode.Create, FileAccess.Write, FileShare.None)) { using (Report report = new ReportDocx(template, output)) { report.ProcessSetup(); // Create the datasource - Northwind. using (AdoDataSourceImpl datasource = new AdoDataSourceImpl("System.Data.SqlClient", "Data Source=mssql.windward.net;Initial Catalog=Northwind;User ID=demo;Password=demo")) { // set the variables to provide list results for each var report.Parameters = adHocVariables; // run the datasource report.ProcessData(datasource, ""); } // and we're done! report.ProcessComplete(); output.Close(); } } } Console.Out.WriteLine(string.Format("Completed: {0}", outputFilename)); System.Diagnostics.Process.Start(outputFilename); }
protected void Page_Load(object sender, EventArgs e) { string basePath = Request.PhysicalApplicationPath + "\\"; // Initialize the engine. License and configuration settings in web.config. Report.Init(); // Open template file FileStream template = File.OpenRead(basePath + "Oracle - Template.docx"); // Create report process Report myReport = new ReportPdf(template); // SQL data source string strConn = "Data Source=oracle.windward.net:1521;Persist Security Info=True;User ID=HR;Password=HR;"; // you can also use the "Oracle.ManagedDataAccess.Client" connector if installed (.NET 4.0 or later only) IReportDataSource data = new AdoDataSourceImpl("Oracle.DataAccess.Client", strConn); // Run the report process myReport.ProcessSetup(); //the second parameter is the name of the data source myReport.ProcessData(data, "ORACLE"); myReport.ProcessComplete(); // Close out of our template file template.Close(); // Opens the finished report //Response.ContentType = "application/pdf"; // this would have the pdf open in the browser (disable content-disposition:attachment if you want this) Response.ContentType = "application/save"; // this is used with content-disposition to give the proper name of the file Response.AppendHeader("content-disposition", "attachment; filename=\"Report.pdf\""); Response.BinaryWrite(((MemoryStream)myReport.GetReport()).ToArray()); Response.End(); // Must be called for MS Office documents }
/// <summary> /// Sample code to set datasets (SQL & XML) using a .rdlx file. /// </summary> /// <param name="args">nothing</param> static void Main(string[] args) { // Initialize the engine Report.Init(); // Open template file and create output file using (FileStream template = new FileStream("../../files/Sample Dataset Template.docx", FileMode.Open, FileAccess.Read, FileShare.Read)) { using (FileStream output = new FileStream("../../files/Sample Dataset Report.pdf", FileMode.Create, FileAccess.Write, FileShare.None)) { // Create report process using (Report myReport = new ReportPdf(template, output)) { // read in the template myReport.ProcessSetup(); // XML datasource using (FileStream xmlFile = new FileStream("../../files/SouthWind.xml", FileMode.Open, FileAccess.Read, FileShare.Read)) using (FileStream xmlSchema = new FileStream("../../files/SouthWind.xsd", FileMode.Open, FileAccess.Read, FileShare.Read)) using (SaxonDataSourceImpl dsSaxon = new SaxonDataSourceImpl(xmlFile, xmlSchema)) using (DataSetImpl dsEmployeesUnder5 = new DataSetImpl("employeesUnder5", "/windward-studios/Employees/Employee[@EmployeeID < 5]", dsSaxon)) using (DataSetImpl dsCustStartA = new DataSetImpl("CustStartA", "/windward-studios/Customers/Customer[starts-with(CompanyName, 'A')]", dsSaxon)) // SQL datasource using (AdoDataSourceImpl dsAdo = new AdoDataSourceImpl("System.Data.SqlClient", "Data Source=mssql.windward.net;Initial Catalog=Northwind;User ID=demo;Password=demo")) using (DataSetImpl dsEmployeesMoreThan5 = new DataSetImpl("EmpMoreThan5", "SELECT * FROM dbo.Employees WHERE(dbo.Employees.EmployeeID > 5)", dsAdo)) using (DataSetImpl dsCustStartWithB = new DataSetImpl("CustStartWithB", "SELECT * FROM dbo.Customers WHERE(dbo.Customers.CompanyName like 'B%')", dsAdo)) { IDictionary <string, IReportDataSource> datasources = new Dictionary <string, IReportDataSource>(); datasources.Add("SW", dsSaxon); datasources.Add("employeesUnder5", dsEmployeesUnder5); datasources.Add("CustStartA", dsCustStartA); datasources.Add("MSSQL", dsAdo); datasources.Add("EmpMoreThan5", dsEmployeesMoreThan5); datasources.Add("CustStartWithB", dsCustStartWithB); myReport.ProcessData(datasources); } // all data applied, finish up the report. myReport.ProcessComplete(); // no need to call close because of the using constructs } } } // Opens the finished report string fullPath = Path.GetFullPath("../../files/Sample Dataset Report.pdf"); Console.Out.WriteLine(string.Format("launching {0}", fullPath)); System.Diagnostics.Process.Start(fullPath); }
static void Main(string[] args) { // Initialize the engine Report.Init(); // Open template file and create output file FileStream template = File.OpenRead("../../../Samples/Variable Invoice Sample - Template.docx"); FileStream output = File.Create("../../../Samples/Variable Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); // SQL data source string strConn = "Data Source=mssql.windwardreports.com;Initial Catalog=Northwind;User ID=demo;Password=demo;"; IReportDataSource data = new AdoDataSourceImpl("System.Data.SqlClient", strConn); //run the report process myReport.ProcessSetup(); //This is where we pass in the parameters Dictionary <string, object> map = new Dictionary <string, object>(); //order is our variable map.Add("order", 10537); //This is the function where we actually tell our report the parameter values myReport.Parameters = map; //the second parameter is the name of the data source myReport.ProcessData(data, "MSSQL"); myReport.ProcessComplete(); //close out of our template file and output output.Close(); template.Close(); // Open the finished report string fullPath = Path.GetFullPath("../../../Samples/Variable Report.pdf"); System.Diagnostics.Process.Start(fullPath); }
static void Main(string[] args) { // if connector is not installed, tell user if (!IsAccessDotNetConnectorInstalled) { throw new ApplicationException("Please install the Access ADO.NET connector to run this example. Details at http://rpt.me/AccessConnector"); } // Initialize the engine Report.Init(); // Open template file and create output file FileStream template = File.OpenRead("../../../Samples/Microsoft Access Datasource Connection - Template.docx"); FileStream output = File.Create("../../../Samples/Access Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); // The data is stored in the Samples folder string fullPathData = Path.GetFullPath("../../../Samples/Northwind - Data.mdb"); // Access data source string strConn = "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=" + fullPathData; IReportDataSource data = new AdoDataSourceImpl("System.Data.Odbc", strConn); //run the report process myReport.ProcessSetup(); //the second parameter is the name of the data source myReport.ProcessData(data, "NWMINIACCESS"); myReport.ProcessComplete(); //close out of our template file and output output.Close(); template.Close(); // Open the finished report string fullPath = Path.GetFullPath("../../../Samples/Access Report.pdf"); System.Diagnostics.Process.Start(fullPath); }
static void Main(string[] args) { // if connector is not installed, tell user if (!IsExcelDotNetConnectorInstalled) { throw new ApplicationException("Please install the Excel ADO.NET connector to run this example. Details at http://rpt.me/ExcelConnector"); } // Initialize the engine Report.Init(); // Open template file and create output file FileStream template = File.OpenRead("../../../Samples/Microsoft Excel File Datasource - Template.docx"); FileStream output = File.Create("../../../Samples/Excel Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); // The data is stored in the Samples folder string fullPathData = Path.GetFullPath("../../../Samples/Northwind Mini - Data.xlsx"); // Excel data source string strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fullPathData + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\""; IReportDataSource data = new AdoDataSourceImpl("System.Data.OleDb", strConn); //run the report process myReport.ProcessSetup(); //the second parameter is the name of the data source myReport.ProcessData(data, "NWMINIXL"); myReport.ProcessComplete(); //close out of our template file and output output.Close(); template.Close(); // Open the finished report string fullPath = Path.GetFullPath("../../../Samples/Excel Report.pdf"); System.Diagnostics.Process.Start(fullPath); }
static void Main(string[] args) { // if connector is not installed, tell user if (!IsOracleDotNetConnectorInstalled) { throw new ApplicationException("Please install the Oracle ADO.NET connector to run this example. Details at http://rpt.me/OracleConnector"); } // Initialize the engine Report.Init(); // Open template file and create output file FileStream template = File.OpenRead("../../../Samples/Oracle - Template.docx"); FileStream output = File.Create("../../../Samples/Oracle Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); // Oracle data source string strConn = "Data Source=oracle.windward.net:1521;Persist Security Info=True;User ID=HR;Password=HR;"; // you can also use the "Oracle.ManagedDataAccess.Client" connector if installed (.NET 4.0 or later only) IReportDataSource data = new AdoDataSourceImpl("Oracle.DataAccess.Client", strConn); //run the report process myReport.ProcessSetup(); //the second parameter is the name of the data source myReport.ProcessData(data, "ORACLE"); myReport.ProcessComplete(); //close out of our template file and output output.Close(); template.Close(); // Open the finished report string fullPath = Path.GetFullPath("../../../Samples/Oracle Report.pdf"); System.Diagnostics.Process.Start(fullPath); }
static void Main(string[] args) { // if connector is not installed, tell user if (!IsDb2DotNetConnectorInstalled) { throw new ApplicationException("Please install the DB2 ADO.NET connector to run this example. Details at http://rpt.me/DB2Connector"); } // Initialize the engine Report.Init(); // Open template file and create output file FileStream template = File.OpenRead("../../../Samples/DB2 - Templates.xlsx"); FileStream output = File.Create("../../../Samples/DB2 Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); // DB2 data source string strConn = "server=db2.windward.net;database=Sample;User ID=demo;Password=demo;"; IReportDataSource data = new AdoDataSourceImpl("IBM.Data.DB2", strConn); //run the report process myReport.ProcessSetup(); //the second parameter is the name of the data source myReport.ProcessData(data, "DB2"); myReport.ProcessComplete(); //close out of our template file and output output.Close(); template.Close(); // Open the finished report string fullPath = Path.GetFullPath("../../../Samples/DB2 Report.pdf"); System.Diagnostics.Process.Start(fullPath); }
static void Main(string[] args) { // if connector is not installed, tell user if (!IsMySqlDotNetConnectorInstalled) { throw new ApplicationException("Please install the MySql ADO.NET connector to run this example. Details at http://rpt.me/MySqlConnector"); } // Initialize the engine Report.Init(); // Open template file and create output file FileStream template = File.OpenRead("../../../Samples/MySQL - Template.docx"); FileStream output = File.Create("../../../Samples/MySQL Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); // MySQL data source string strConn = "server=mysql.windward.net;database=sakila;user id=test;password=test;"; IReportDataSource data = new AdoDataSourceImpl("MySql.Data.MySqlClient", strConn); //run the report process myReport.ProcessSetup(); //the second parameter is the name of the data source myReport.ProcessData(data, "MYSQL"); myReport.ProcessComplete(); //close out of our template file and output output.Close(); template.Close(); // Open the finished report string fullPath = Path.GetFullPath("../../../Samples/MySQL Report.pdf"); System.Diagnostics.Process.Start(fullPath); }
protected void Page_Load(object sender, EventArgs e) { string basePath = Request.PhysicalApplicationPath + "\\"; // Initialize the engine. License and configuration settings in web.config. Report.Init(); // Open template file FileStream template = File.OpenRead(basePath + "Microsoft Access Datasource Connection - Template.docx"); // Create report process Report myReport = new ReportPdf(template); // The data is stored in the Samples folder string fullPathData = basePath + "Northwind - Data.mdb"; // Access data source string strConn = "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=" + fullPathData; IReportDataSource data = new AdoDataSourceImpl("System.Data.Odbc", strConn); // Run the report process myReport.ProcessSetup(); //the second parameter is the name of the data source myReport.ProcessData(data, "NWMINIACCESS"); myReport.ProcessComplete(); // Close out of our template file template.Close(); // Opens the finished report //Response.ContentType = "application/pdf"; // this would have the pdf open in the browser (disable content-disposition:attachment if you want this) Response.ContentType = "application/save"; // this is used with content-disposition to give the proper name of the file Response.AppendHeader("content-disposition", "attachment; filename=\"Report.pdf\""); Response.BinaryWrite(((MemoryStream)myReport.GetReport()).ToArray()); Response.End(); // Must be called for MS Office documents }