protected void Button1_Click(object sender, EventArgs e) { int row = Convert.ToInt16(TextBox1.Text.Trim()); int column = Convert.ToInt16(TextBox2.Text.Trim()); int rowNumber = Convert.ToInt16(TextBox3.Text.Trim()); int columnNumber = Convert.ToInt16(TextBox4.Text.Trim()); GridWorksheet sheet = GridWeb1.WorkSheets[0]; sheet.FreezePanes(row, column, rowNumber, columnNumber); }
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 GridWorksheet sheet = GridWeb1.WorkSheets[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"].Style.Font.Size = new FontUnit("20pt"); sheet.Cells["A1"].Style.HorizontalAlign = HorizontalAlign.Center; sheet.Cells["A1"].Style.VerticalAlign = VerticalAlign.Middle; sheet.Cells["A1"].Style.BackColor = Color.SkyBlue; sheet.Cells["A1"].Style.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(); } }
private void LoadData() { // Gets the web application's path. string path = Server.MapPath("~"); path = path.Substring(0, path.LastIndexOf("\\")); string fileName = path + "\\File\\FreezePane.xls"; // Imports from a Grid file. GridWeb1.ImportExcelFile(fileName); GridWorksheet sheet = GridWeb1.WorkSheets[0]; sheet.FreezePanes(3, 3, 3, 3); }
protected void btnFreeze_Click(object sender, EventArgs e) { if (Page.IsValid) { // ExStart:FreezePanes // Get user inputs for row, column, number of rows and number of columns int row = Convert.ToInt16(txtRow.Text.Trim()); int column = Convert.ToInt16(txtColumn.Text.Trim()); int noOfRows = Convert.ToInt16(txtNoOfRows.Text.Trim()); int noOfColumns = Convert.ToInt16(txtNoOfColumns.Text.Trim()); // Accessing the reference of the worksheet that is currently active GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; // Freeze desired rows and columns sheet.FreezePanes(row, column, noOfRows, noOfColumns); // ExEnd:FreezePanes } }