Aspose.Cells.GridWeb.Examples.CSharp.Articles.BindDataUsingWorksheetDesigner.BindWithInSheetHeaders C# (CSharp) Метод

BindWithInSheetHeaders() приватный Метод

private BindWithInSheetHeaders ( ) : void
Результат void
        private void BindWithInSheetHeaders()
        {
            // Create dataset object
            this.dataSet11 = new DataSet1();

            // Create database object
            ExampleDatabase db = new ExampleDatabase();

            // Create path to database file
            string path = (this.Master as Site).GetDataDir();

            // Create connection string
            db.oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "\\Miscellaneous\\Database\\demos.mdb";
            try
            {
                // Connects to database and fetches data.
                db.oleDbDataAdapter1.Fill(dataSet11);

                // Create webworksheet object
                WebWorksheet sheet = GridWeb1.WebWorksheets[0];

                // Clears the sheet.
                sheet.Cells.Clear();

                // Enables creating in-sheet headers.
                sheet.EnableCreateBindColumnHeader = true;

                // Data cells begin from row 2.
                sheet.BindStartRow = 2;

                // Creates some title cells.
                sheet.Cells["A1"].PutValue("The Product Table");
                sheet.Cells["A1"].GetStyle().Font.Size = new FontUnit("20pt");
                sheet.Cells["A1"].GetStyle().HorizontalAlign = HorizontalAlign.Center;
                sheet.Cells["A1"].GetStyle().VerticalAlign = VerticalAlign.Middle;
                sheet.Cells["A1"].GetStyle().BackColor = Color.SkyBlue;
                sheet.Cells["A1"].GetStyle().ForeColor = Color.Blue;
                sheet.Cells.Merge(0, 0, 2, 11);

                // Freezes the header rows.
                sheet.FreezePanes(3, 0, 3, 0);

                // Bind the sheet to the dataset.
                sheet.DataBind();
            }
            finally
            {
                //Close connection
                db.oleDbConnection1.Close();
            }
        }