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/Windward Trucking 2 - Template.docx"); FileStream output = File.Create("../../../Samples/Xml Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); // Open an inputfilestream for our data file FileStream Xml = File.OpenRead("../../../Samples/Windward Trucking 2 - Data.xml"); // Open a data object to connect to our xml file IReportDataSource data = new XmlDataSourceImpl(Xml, false); // Run the report process myReport.ProcessSetup(); // The second parameter is "" to tell the process that our data is the default data source myReport.ProcessData(data, ""); myReport.ProcessComplete(); // Close out of our template file and output output.Close(); template.Close(); Xml.Close(); // Opens the finished report string fullPath = Path.GetFullPath("../../../Samples/Xml Report.pdf"); 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/Windward OData - Template.docx"); FileStream output = File.Create("../../../Samples/OData Report.pdf"); //Create report process Report myReport = new ReportPdf(template, output); //Run the report process myReport.ProcessSetup(); //Datasource connection code for 'ODataSample' (datasource name inside template) IReportDataSource ODataSampleData = new ODataDataSourceImpl("Url=http://services.odata.org/northwind/northwind.svc/;Version=3"); var dataSources = new Dictionary <string, IReportDataSource>() { { "ODataSample", ODataSampleData } }; myReport.ProcessData(dataSources); myReport.ProcessComplete(); //Close out of our template file and output output.Close(); template.Close(); //Open the finished report string fullPath = Path.GetFullPath("../../../Samples/OData 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); }
static void Main(string[] args) { // Initialize the engine Report.Init(); // Open template file and create output file FileStream template = File.OpenRead("../../../Samples/JSON - Template.docx"); FileStream output = File.Create("../../../Samples/Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); // Connect to our JSON database IReportDataSource data = new JsonDataSourceImpl("http://json.windward.net/Northwind.json", JsonDataSourceImpl.MODE.CONNECTION_STRING); // Run the report process myReport.ProcessSetup(); // The second parameter is "" to tell the process that our data is the default data source myReport.ProcessData(data, ""); myReport.ProcessComplete(); // Close out of our template file and output output.Close(); template.Close(); // Opens the finished report string fullPath = Path.GetFullPath("../../../Samples/Report.pdf"); 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("../../../../../Data/Samples/Source/WW-Common List.docx"); FileStream output = File.Create("../../../../../Data/Samples/Destination/Xml Common List.docx"); // Create report process Report myReport = new ReportPdf(template, output); // Open an inputfilestream for our data file FileStream Xml = File.OpenRead("../../../../../Data/Data Source/WW-Customers.xml"); // Open a data object to connect to our xml file IReportDataSource data = new XmlDataSourceImpl(Xml, false); // Run the report process myReport.ProcessSetup(); // The second parameter is "" to tell the process that our data is the default data source myReport.ProcessData(data, "Customers"); myReport.ProcessComplete(); // Close out of our template file and output output.Close(); template.Close(); Xml.Close(); // Opens the finished report string fullPath = Path.GetFullPath("../../../../../Data/Samples/Destination/Xml Common List.docx"); 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/template.docx"); FileStream output = File.Create("../../../Samples/Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); // Salesforce data source SFDataSourceImpl data = new SFDataSourceImpl(@"*****@*****.**", @"w1ndw@rd", "BtqoH7pIR6rkR0fwh1YU156Hp", true); //run the report process myReport.ProcessSetup(); //the second parameter is the name of the data source myReport.ProcessData(data, "sfdemo"); myReport.ProcessComplete(); //close out of our template file and output output.Close(); template.Close(); // Open the finished report string fullPath = Path.GetFullPath("../../../Samples/Report.pdf"); 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/Windward Trucking 2 - Template.docx"); FileStream output = File.Create("../../../Samples/Xml Report.pdf"); // Create report process Report myReport = new ReportPdf(template, output); // Open a data object to connect to our xml file string url = Path.GetFullPath("../../../Samples/Windward Trucking 2 - Data.xml"); string xsd = null; IReportDataSource data = new SaxonDataSourceImpl(string.Format("Url={0}", url), xsd); // Run the report process myReport.ProcessSetup(); // The second parameter is "" to tell the process that our data is the default data source myReport.ProcessData(data, "sax"); myReport.ProcessComplete(); // Close out of our template file and output data.Close(); output.Close(); template.Close(); // Opens the finished report string fullPath = Path.GetFullPath("../../../Samples/Xml Report.pdf"); 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/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); }
static void Main(string[] args) { //Initialize the engine Report.Init(); //Open template file and create output file FileStream template = File.OpenRead("../../../Samples/Sharepoint with OData - Template.docx"); FileStream output = File.Create("../../../Samples/Sharepoint Report.pdf"); //Create report process Report myReport = new ReportPdf(template, output); //Run the report process myReport.ProcessSetup(); //Datasource connection code for 'ODataSample' (datasource name inside template) IReportDataSource ODataSampleData = new ODataDataSourceImpl("http://sharepointdemo.windward.net/_vti_bin/listdata.svc/", "windwarddemo\\demo", "demo", FileUtils.CONNECT_MODE.CREDENTIALS, 2); var dataSources = new Dictionary <string, IReportDataSource>() { { "sp", ODataSampleData } }; myReport.ProcessData(dataSources); myReport.ProcessComplete(); //Close out of our template file and output output.Close(); template.Close(); //Open the finished report string fullPath = Path.GetFullPath("../../../Samples/Sharepoint Report.pdf"); System.Diagnostics.Process.Start(fullPath); }
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); }
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 }
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 }
/// <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); }
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 + "JSON - Template.docx"); // Create report process Report myReport = new ReportPdf(template); // Open data file WebClient client = new WebClient(); Stream Json = client.OpenRead("http://json.windward.net/northwind.json"); // Make a data object to connect to our xml file IReportDataSource data = new JsonDataSourceImpl(Json); // Run the report process myReport.ProcessSetup(); // The second parameter is "" to tell the process that our data is the unnamed data source myReport.ProcessData(data, ""); myReport.ProcessComplete(); // Close out of our template file template.Close(); Json.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 }
static void Main(string[] args) { // Initialize the engine Report.Init(); // Open template file and create output file FileStream template = File.OpenRead("../../../Samples/MSDynamics CRM - Template.docx"); FileStream output = File.Create("../../../Samples/OData Report.pdf"); Report myReport = new ReportPdf(template, output); // To connect we first we need to grab the security access token, here we use Windward's example implementation // of WS-Trust authenticator and you can change AuthenticateWithWsTrust() to be AuthenticateWithOAuthPrompt() here. // Also you can replace the authenticator with your own implementation and pass it's token into WrCredentials instead. var authToken = WsTrustAuthenticate(); var securityTokenCredentials = new WrCredentials { SecurityToken = authToken.AccessToken }; var datasource = new ODataDataSourceImpl(serviceUrl, securityTokenCredentials, FileUtils.CONNECT_MODE.SECURITY_TOKEN, 2); // Run the report process myReport.ProcessSetup(); // The second parameter is "" to tell the process that our data is the default data source myReport.ProcessData(datasource, ""); myReport.ProcessComplete(); // Close out of our template file and output output.Close(); template.Close(); // Opens the finished report string fullPath = Path.GetFullPath("../../../Samples/OData 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 }
/** * Sample document demonstrating how to include Error Handling into a java app and print the error stream to a .txt file * * @author Adam Austin */ static void Main(string[] args) { try { // Initialize the engine Report.Init(); // To generate a report, first we need a Report object. For now, we're using the // pdf format to output. FileStream template = File.OpenRead("../../../Samples/Smart Energy Template.docx"); FileStream reportStream = File.Create("../../../Samples/report.pdf"); Report report = new ReportPdf(template, reportStream); // Preparation... Console.Out.WriteLine("Generating report..."); report.ProcessSetup(); // Set Track Verify and Error Handling issues during report generation based off a command line argument string trackErrorSetting = ""; if (args.Length > 0) { trackErrorSetting = args[0]; } switch (trackErrorSetting) { case ("0"): Console.Out.WriteLine("Track Errors: None"); report.TrackErrors = (int)Report.ERROR_HANDLING.NONE; break; case ("1"): Console.Out.WriteLine("Track Errors: Error Handling"); report.TrackErrors = (int)Report.ERROR_HANDLING.TRACK_ERRORS; break; case ("2"): Console.Out.WriteLine("Track Errors: Verify"); report.TrackErrors = (int)Report.ERROR_HANDLING.VERIFY; break; case ("3"): default: Console.Out.WriteLine("Track Errors: All"); report.TrackErrors = (int)Report.ERROR_HANDLING.ALL; break; } // Set up the data hash map. var dataProviders = new Dictionary <string, IReportDataSource>(); // Create an instance of DataSourceProvider System.Xml.XPath.XPathDocument Xml1 = new System.Xml.XPath.XPathDocument(File.OpenRead("../../../Samples/Smart Energy - Broken.xml")); IReportDataSource datasource = new XmlDataSourceImpl(Xml1); // Add the data source to the data hash map dataProviders.Add("", datasource); // Process the data stored in the hash map report.ProcessData(dataProviders); // And... DONE! report.ProcessComplete(); reportStream.Close(); template.Close(); // Print errors found by Error Handling and Verify to the command line and the file "Issues.txt" ErrorInfo outputissues = report.GetErrorInfo(); java.util.List errors = outputissues.getErrors(); Console.Out.WriteLine(); Console.Out.WriteLine("---------------------------------------------------"); Console.Out.WriteLine("Errors found during Verify upon Report Generation:"); Console.Out.WriteLine("---------------------------------------------------"); using (System.IO.StreamWriter file = new System.IO.StreamWriter("../../../Samples/Issues.txt")) { file.WriteLine("---------------------------------------------------"); file.WriteLine("Errors found by Verify upon Report Generation:"); file.WriteLine("---------------------------------------------------"); // Print every issue to the command line and the isseus.txt file for (int i = 0; i < errors.size(); i++) { Console.Out.WriteLine(((Issue)errors.get(i)).getMessage()); file.WriteLine(((Issue)errors.get(i)).getMessage()); } } } catch (Exception e) { Console.Out.WriteLine(e.StackTrace.ToString()); } Console.Out.WriteLine("\n\nGeneration finished. Click \"Enter\" to dismiss window."); Console.In.Read(); }
/// <summary> /// Create a report using Windward Reports. /// </summary> /// <param name="args">run with no parameters to list out usage.</param> static void Main(string[] args) { // // added this code to allow the example to run with a default set of parameters and return a result // //hard-code the arguments for the sample templates that ship with the example CommandLine cmdLine; if (args.Length < 2) { string[] exargs = { "InternetMarketingReport.docx", "testxmlreport.pdf", "-xml:INTMARKETING", "InternetMarketingData.xml" }; // if no arguments, then we list out the usage. Console.WriteLine("\n\n\nPress any key to display the usage parameters..."); Console.ReadKey(); DisplayUsage(); Console.WriteLine("\n\n\nPress any key to run the example with default parameters..."); Console.ReadKey(); cmdLine = CommandLine.Factory(exargs); } else { cmdLine = CommandLine.Factory(args); } // // Uncomment the following code to allow processing of the commandline parameters (other than the defaults) //and change all references from "exargs" to "args" // if no arguments, then we list out the usage. //if (args.Length < 2) // { // DisplayUsage(); // return; // } // parse the arguments passed in. This method makes no calls to Windward, it merely organizes the passed in arguments. // the try here is so we can print out an exception if it is thrown. This code does minimal error checking and no other // exception handling to keep it simple & clear. try { // This turns on log4net logging. You can also call log4net.Config.XmlConfigurator.Configure(); directly. // If you do not make this call, then there will be no logging (which you may want off). BasicConfigurator.Configure(); // Initialize the reporting engine. This will throw an exception if the engine is not fully installed or you // do not have a valid license key in RunReportXml.exe.config. Report.Init(); // get the template and output file streams. using (Stream template = new FileStream(cmdLine.TemplateFilename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (Stream output = new FileStream(cmdLine.ReportFilename, FileMode.Create, FileAccess.Write, FileShare.None)) { Console.Out.WriteLine(string.Format("Template: {0}", cmdLine.TemplateFilename)); Console.Out.WriteLine(string.Format("Report: {0}", cmdLine.ReportFilename)); // Create the report object, based on the file extension using (Report report = new ReportPdf(template, output)) { // This first call parses the template and prepares the report so we can apply data to it. report.ProcessSetup(); // If we have a datasource, we set it up. if (!string.IsNullOrEmpty(cmdLine.DatasourceFilename)) { Console.Out.WriteLine(string.Format("XML datasource: {0}", cmdLine.DatasourceFilename)); using (Stream dsStream = new FileStream(cmdLine.DatasourceFilename, FileMode.Open, FileAccess.Read)) { using (XmlDataSourceImpl datasource = new XmlDataSourceImpl(dsStream, false)) { // Assign any passed variables. report.Parameters = cmdLine.Map; // this applies the datasource to the report populating the tags. report.ProcessData(datasource, cmdLine.DatasourceName); } } } // Now that all the data has been applied, we generate the final output report. This does the // page layout and then writes out the output file. report.ProcessComplete(); Console.Out.WriteLine(string.Format("{0} built, {1} pages long", cmdLine.ReportFilename, report.NumPages)); // need a launcher for the result Process.Start(cmdLine.ReportFilename); } } } } catch (Exception ex) { while (ex != null) { Console.Error.WriteLine(string.Format("Error: {0}\n stack: {1}\n", ex.Message, ex.StackTrace)); ex = ex.InnerException; } throw; } }
static void Main(string[] args) { if (string.IsNullOrEmpty(fromEmailAddress) || string.IsNullOrEmpty(toEmailAddress) || string.IsNullOrEmpty(emailServer)) { Console.Error.WriteLine("please enter values for email address, password, server, etc."); Console.Out.WriteLine("press any key to cancel program"); Console.ReadKey(); return; } const string subject = "Windward Reports Test Message"; const string body = "The report is attached to this email"; MailAddress fromAddress = new MailAddress(fromEmailAddress); MailAddress toAddress = new MailAddress(toEmailAddress); // gmail uses port 587 SmtpClient smtp; if (emailServer.ToLower().Contains(".gmail.")) { smtp = new SmtpClient() { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword), Timeout = 10000 } } ; else { smtp = new SmtpClient(emailServer); if (!string.IsNullOrEmpty(fromPassword)) { smtp.Credentials = new System.Net.NetworkCredential(fromAddress.Address, fromPassword); } } // Initialize the engine Report.Init(); // Open template file and create output stream FileStream template = File.OpenRead("../../../Samples/Email Example Template.docx"); MemoryStream output = new MemoryStream(); // Create report process ReportPdf myReport = new ReportPdf(template, output); // Open an inputfilestream for our data file FileStream Xml = File.OpenRead("../../../Samples/Windward Trucking 2 - Data.xml"); // Open a data object to connect to our xml file IReportDataSource data = new XmlDataSourceImpl(Xml, false); // Run the report process myReport.ProcessSetup(); // The second parameter is the name of the data source myReport.ProcessData(data, "FD"); myReport.ProcessComplete(); using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { // Sets up the name and file type of the stream System.Net.Mime.ContentType content = new System.Net.Mime.ContentType(); content.MediaType = System.Net.Mime.MediaTypeNames.Application.Pdf; content.Name = "test.pdf"; output.Position = 0; // reset the position to the beginning of the stream - Don't forget! System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(output, content); message.Attachments.Add(attachment); smtp.Send(message); } //close out of our template file and output template.Close(); Xml.Close(); output.Close(); }