Esempio n. 1
0
        public void AutoRun()
        {
            using (FlexCelReport ordersReport = SharedData.CreateReport())
            {
                ordersReport.SetValue("Date", DateTime.Now);
                ordersReport.SetValue("ReportCaption", "Sales by year and country");

                using (DataSet ds = new DataSet())
                {
                    SharedData.Fill(ds, @"SELECT Employees.Country, SUM([Order Details].UnitPrice * [Order Details].Quantity) AS Sales, COUNT([Order Details].Quantity) AS OrderCount, DatePart(yyyy, Orders.OrderDate) AS SaleYear, DatePart(q, Orders.OrderDate) AS Quarter FROM ((Employees INNER JOIN Orders ON Employees.EmployeeID = Orders.EmployeeID) INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID) GROUP BY Employees.Country, DatePart(yyyy, Orders.OrderDate), DatePart(q, Orders.OrderDate)", "Data");
                    ordersReport.AddTable(ds);
                    string DataPath = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."), "..") + Path.DirectorySeparatorChar;

                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        ordersReport.Run(DataPath + "Master Detail on one Table.template.xls", saveFileDialog1.FileName);

                        if (MessageBox.Show("Do you want to open the generated file?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            Process.Start(saveFileDialog1.FileName);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void genericReport_UserTable(object sender, UserTableEventArgs e)
        {
            DataSet ds = new DataSet();

            //On this example we will just return the table with the name specified on parameters
            //but you could return whatever you wanted here.
            //As always, remember to *validate* what the user can enter on the parameters string.

            switch (e.Parameters.ToUpper(CultureInfo.InvariantCulture))
            {
            case "SUPPLIERS":
                SharedData.Fill(ds, "select * from suppliers", e.TableName);
                break;

            case "CATEGORIES":
                SharedData.Fill(ds, "select * from categories", e.TableName);
                break;

            case "PRODUCTS":
                SharedData.Fill(ds, "select * from products", e.TableName);
                break;

            default: throw new Exception("Invalid parameter to user table: " + e.Parameters);
            }

            ((FlexCelReport)sender).AddTable(ds, TDisposeMode.DisposeAfterRun);
        }