コード例 #1
0
ファイル: FrmGenView.cs プロジェクト: leofemmy/TSS_Ogun
        private XtraReport CreateReport()
        {
            // Create a blank report.
            XtraReport rep = new XtraReport();

            // Create a detail band and add it to the report.
            DetailBand detail = new DetailBand();

            rep.Bands.Add(detail);

            // Create a pivot grid and add it to the Detail band.
            XRPivotGrid pivotGrid = new XRPivotGrid();

            detail.Controls.Add(pivotGrid);

            DataSet dataSet1 = new DataSet();

            using (SqlDataAdapter ada = new SqlDataAdapter((string)string.Format("SELECT Period,AccountNo,OpenBal,CloseBal,TransDescription,BankName,BankShortCode,Amount FROM ViewIGRAccountDetails WHERE CONVERT(VARCHAR(10),StartDate,103)='{0}' AND CONVERT(VARCHAR(10),EndDate,103)='{1}'", string.Format("{0:dd/MM/yyy}", dtpStart.Value), string.Format("{0:dd/MM/yyy}", dtpEnd.Value)), Logic.ConnectionString))
            {
                ada.Fill(dataSet1, "table");
            }

            // Creata a dataset and fill it.
            //DataSet dataSet1 = new DataSet();
            //adapter.Fill(dataSet1, "SalesPerson");


            // Bind the pivot grid to data.
            pivotGrid.DataSource = dataSet1;
            pivotGrid.DataMember = "SalesPerson";

            XRControl xrControl1 = new XRControl();

            XRLabel label1 = new XRLabel();

            //pivotGrid = xrControl1 as XRPivotGrid;


            pivotGrid.Appearance.Cell.Font = new System.Drawing.Font("Times New Roman", 8F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Regular))));

            //pivotGrid.Appearance.Cell
            // Generate pivot grid's fields.

            XRPivotGridField fieldCategoryName = new XRPivotGridField("BankName", PivotArea.RowArea)
            {
                AreaIndex = 0, Width = 150
            };

            fieldCategoryName.CellFormat.FormatType   = DevExpress.Utils.FormatType.Custom;
            fieldCategoryName.CellFormat.FormatString = "({0})";

            XRPivotGridField fieldCountry = new XRPivotGridField("TransDescription", PivotArea.ColumnArea)
            {
                AreaIndex = 0, Width = 120
            };


            XRPivotGridField fieldQuantity = new XRPivotGridField("Amount", PivotArea.DataArea)
            {
                AreaIndex = 0, Width = 80
            };

            fieldQuantity.CellFormat.FormatType             = DevExpress.Utils.FormatType.Numeric;
            fieldQuantity.CellFormat.FormatString           = "{0:n2}";
            fieldQuantity.GrandTotalCellFormat.FormatType   = DevExpress.Utils.FormatType.Numeric;
            fieldQuantity.GrandTotalCellFormat.FormatString = "{0:n2}";
            fieldQuantity.TotalCellFormat.FormatType        = DevExpress.Utils.FormatType.Numeric;
            fieldQuantity.TotalValueFormat.FormatString     = "{0:n2}";

            //label1 = (string)fieldCountry;



            pivotGrid.OptionsView.ShowColumnHeaders = false;

            pivotGrid.OptionsView.ShowColumnGrandTotals = false;

            //pivotGrid.OptionsView.ShowColumnHeaders = false;
            pivotGrid.OptionsView.ShowDataHeaders = false;

            pivotGrid.OptionsView.ShowRowHeaders = true;

            //pivotGrid.Fields["TransDescription"].BestFit();
            //fieldOrderDate.RowValueLineCount = 3;
            //xrControl1.WordWrap = true;

            //fieldCategoryName.CollapseAll();

            //xrControl1 = (object)fieldCategoryName;
            // Add these fields to the pivot grid.
            //pivotGrid.Fields.AddRange(new PivotGridField[] {fieldCategoryName, fieldCountry,
            //     fieldQuantity});

            pivotGrid.Fields.AddRange(new XRPivotGridField[] { fieldCategoryName, fieldCountry, fieldQuantity });
            pivotGrid.CanShrink = true;

            //pivotGrid.BestFit();
            return(rep);
        }
コード例 #2
0
      private XtraReport CreateReport()
      {
          // Create a blank report.
          XtraReport crossTabReport = new XtraReport();

          // Create a detail band and add it to the report.
          DetailBand detail = new DetailBand();
          crossTabReport.Bands.Add(detail);

          // Create a pivot grid and add it to the Detail band.
          XRPivotGrid pivotGrid = new XRPivotGrid();
          detail.Controls.Add(pivotGrid);

          //// Create a data connection.
          //OleDbConnection connection = new
          //OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\nwind.mdb");

          //// Create a data adapter.
          //OleDbDataAdapter adapter = new OleDbDataAdapter(
          //"SELECT CategoryName, ProductName, Country, [Sales Person], Quantity, [Extended Price] FROM SalesPerson",
          //connection);

          //// Creata and populate a dataset.
          //DataSet dataSet1 = new DataSet();
          //adapter.Fill(dataSet1, "SalesPerson");

          // Bind the pivot grid to data.
          pivotGrid.DataSource = GetList();
        //  pivotGrid.DataMember = "SalesPerson";

          // Generate pivot grid's fields.
         
          XRPivotGridField fieldProductName = new XRPivotGridField("LineNo", PivotArea.RowArea);
          XRPivotGridField fieldDate = new XRPivotGridField("Date", PivotArea.RowArea);
          XRPivotGridField fieldCountry = new XRPivotGridField("Size", PivotArea.ColumnArea);
         
          XRPivotGridField fieldQuantity = new XRPivotGridField("Pcs", PivotArea.DataArea);
          fieldDate.ValueFormat.FormatString = "d";

          // Add these fields to the pivot grid.
          pivotGrid.Fields.AddRange(new XRPivotGridField[] {fieldDate, fieldProductName, fieldCountry,
         fieldQuantity});

          return crossTabReport;
      }