Connecting the library to your project NetReport

  1. Add References to NetReport.dll in your project.
  2. Add around the following code into your program:

            ////////////////////
            // Generate report
            string pathTmpl = ""; // _variable that will contain the path to the created report_
            using (IAZ.netreports.NetReport netReport = new IAZ.netreports.NetReport("Templates\\templates.xml"))
            {
                netReport.SetInitstring(Properties.Settings.Default.TestNetReportsDBConnectionString);
                netReport.SetReport("TestPeople");

                pathTmpl = "output\\" + DateTime.Now.ToString("yyyyMMdd") + "\\";
                if (!netReport.Generate("TestPeopleTmpl", ref pathTmpl))
                {
                    MessageBox.Show("The report was not created.", "Message", MessageBoxButton.OK);
                    return;
                }
            }

            // Opening a report
            MessageBoxResult res = MessageBox.Show("The report was successfully created. Open it?\n(\"" + pathTmpl + "\")",
                "Message", MessageBoxButton.YesNo, MessageBoxImage.Question);
            if (res == MessageBoxResult.Yes)
            {
                using (Process docExcel = new Process())
                {
                    docExcel.StartInfo.FileName = pathTmpl;
                    docExcel.StartInfo.Verb = "Open";
                    docExcel.StartInfo.CreateNoWindow = false;
                    docExcel.Start();
                }
            }


Complete example of creating a program to generate a report, you can download from this site.

Last edited Jan 21, 2011 at 10:35 AM by iaz, version 5

Comments

No comments yet.