コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && !GridWeb1.IsPostBack)
            {
                // Create dataset object
                this.dataSet11 = new Aspose.Cells.GridWeb.DemosCS.DataBind.DataSet1();

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

                // Specifies the datasource for the sheet.
                sheet.DataSource = dataSet11;
                sheet.DataMember = "Products";

                // Creates in-sheet column headers.
                sheet.EnableCreateBindColumnHeader = true;

                // Data cells begin at row 1;
                sheet.BindStartRow = 1;

                // Creates the data field column automatically.
                sheet.CreateAutoGenratedColumns();

                // Modifies a column's number type.
                sheet.BindColumns["UnitPrice"].NumberType = NumberType.Currency3;

                // The "product name" field is required.
                Aspose.Cells.GridWeb.Validation v = new Aspose.Cells.GridWeb.Validation();
                v.IsRequired = true;
                sheet.BindColumns["ProductName"].Validation = v;

                // Modifies column headers' background color.
                for (int i = 0; i < sheet.BindColumns.Count; i++)
                {
                    sheet.BindColumns[i].ColumnHeaderStyle.BackColor = Color.SkyBlue;
                }

                // Create demo 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
                {
                    // Loads data from database.
                    db.oleDbDataAdapter1.Fill(dataSet11);
                }
                finally
                {
                    // Close connection
                    db.oleDbConnection1.Close();
                }

                // Binding.
                sheet.DataBind();
            }
        }
コード例 #2
0
    private void BindWithInSheetHeaders()
    {
      //Create dataset object
      this.dataSet11 = new Aspose.Cells.GridWeb.DemosCS.DataBind.DataSet1();

      //Create demo database object
      DemoDatabase db = new DemoDatabase();

      //Create pathe to database file
      string path = Server.MapPath("~");
      path = path.Substring(0, path.LastIndexOf("\\"));	 

      //Create connection string
      db.oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "\\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();
      }
    }
コード例 #3
0
    private void BindWithInSheetHeaders()
    {
        //Create dataset object
        this.dataSet11 = new Aspose.Cells.GridWeb.DemosCS.DataBind.DataSet1();

        //Create demo database object
        DemoDatabase db = new DemoDatabase();

        //Create pathe to database file
        string path = Server.MapPath("~");

        path = path.Substring(0, path.LastIndexOf("\\"));

        //Create connection string
        db.oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "\\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();
        }
    }
コード例 #4
0
        private void BindWithoutInSheetHeaders()
        {
            // Create dataset object
            this.dataSet11 = new Aspose.Cells.GridWeb.DemosCS.DataBind.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 web worksheet object
                WebWorksheet sheet = GridWeb1.WebWorksheets[0];

                // Clears the sheet.
                sheet.Cells.Clear();
                sheet.Cells.UnMerge(0, 0, 2, 11);

                // Disables creating in-sheet headers.
                sheet.EnableCreateBindColumnHeader = false;

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

                // Unfreezes the header rows.
                sheet.UnfreezePanes();

                // Bind the sheet to the dataset.
                sheet.DataBind();
            }
            finally
            {
                // Close database connection
                db.oleDbConnection1.Close();
            }
        }
コード例 #5
0
    private void BindWithoutInSheetHeaders()
    {
      //Create database object
      this.dataSet11 = new Aspose.Cells.GridWeb.DemosCS.DataBind.DataSet1();

      //Create demo database object
      DemoDatabase db = new DemoDatabase();

      //Create path to database file
      string path = Server.MapPath("~");
      path = path.Substring(0, path.LastIndexOf("\\"));	 

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

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

        // Clears the sheet.
        sheet.Cells.Clear();
        sheet.Cells.UnMerge(0, 0, 2, 11);
        // Disables creating in-sheet headers.
        sheet.EnableCreateBindColumnHeader = false;

        // Data cells begin from row 0.
        sheet.BindStartRow = 0;
        // Unfreezes the header rows.
        sheet.UnfreezePanes();
        // Bind the sheet to the dataset.
        sheet.DataBind();

       
      }
      finally
      {
        //Close database connection
        db.oleDbConnection1.Close();
      }
    }
コード例 #6
0
    private void BindWithoutInSheetHeaders()
    {
        //Create dataset object
        this.dataSet11 = new Aspose.Cells.GridWeb.DemosCS.DataBind.DataSet1();

        //Create demo database object
        DemoDatabase db = new DemoDatabase();

        //Create path to database file
        string path = Server.MapPath("~");

        path = path.Substring(0, path.LastIndexOf("\\"));

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

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

            // Create the "CategoryID" field dropdownlist value list.
            sheet.BindColumns["CategoryID"].Validation.ValidationType = ValidationType.List;
            sheet.BindColumns["CategoryID"].Validation.LoadValueList(dataSet11.Categories.DefaultView, "CategoryID", "CategoryName", true);

            // Bind the sheet to the dataset.
            sheet.DataSource = dataSet11;
            sheet.DataBind();
        }
        finally
        {
            //Close database connection
            db.oleDbConnection1.Close();
        }
    }
コード例 #7
0
  private void BindWithoutInSheetHeaders()
  {
    //Create dataset object
    this.dataSet11 = new Aspose.Cells.GridWeb.DemosCS.DataBind.DataSet1();

    //Create demo database object
    DemoDatabase db = new DemoDatabase();

    //Create path to database file
    string path = Server.MapPath("~");
    path = path.Substring(0, path.LastIndexOf("\\"));	

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

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

      // Create the "CategoryID" field dropdownlist value list.
      sheet.BindColumns["CategoryID"].Validation.ValidationType = ValidationType.List;
      sheet.BindColumns["CategoryID"].Validation.LoadValueList(dataSet11.Categories.DefaultView, "CategoryID", "CategoryName", true);

      // Bind the sheet to the dataset.
      sheet.DataSource = dataSet11;
      sheet.DataBind();
    }
    finally
    {
      //Close database connection
      db.oleDbConnection1.Close();
    }
  }
コード例 #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
      if (!IsPostBack&&!GridWeb1.IsPostBack)
      {
        //Create dataset object
        this.dataSet11 = new Aspose.Cells.GridWeb.DemosCS.DataBind.DataSet1();

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

        // Specifies the datasource for the sheet.
        sheet.DataSource = dataSet11;
        sheet.DataMember = "Products";

        // Creates in-sheet column headers.
        sheet.EnableCreateBindColumnHeader = true;

        // Data cells begin at row 1;
        sheet.BindStartRow = 1;

        // Creates the data field column automatically.
        sheet.CreateAutoGenratedColumns();

        // Modifies a column's number type.
        sheet.BindColumns["UnitPrice"].NumberType = NumberType.Currency3;

        // The "product name" field is required.
        Aspose.Cells.GridWeb.Validation v = new Aspose.Cells.GridWeb.Validation();
        v.IsRequired = true;
        sheet.BindColumns["ProductName"].Validation = v;

        // Modifies column headers' background color.
        for (int i = 0; i < sheet.BindColumns.Count; i++)
        {
          sheet.BindColumns[i].ColumnHeaderStyle.BackColor = Color.SkyBlue;
        }

        //Create demo database object
        DemoDatabase db = new DemoDatabase();

        //Create path to database file
        string path = Server.MapPath("~");
        path = path.Substring(0, path.LastIndexOf("\\"));

        //Create connection string 
        db.oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + "\\Database\\demos.mdb";
        try
        {
          // Loads data from database.
          db.oleDbDataAdapter1.Fill(dataSet11);
        }
        finally
        {
          //Close connection
          db.oleDbConnection1.Close();
        }

        // Binding.
        sheet.DataBind();
      }
    }