protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false && this.GridWeb1.IsPostBack == false) { //Access the first worksheet GridWorksheet gridSheet = GridWeb1.WorkSheets[0]; //Input data into the cells of the first worksheet. gridSheet.Cells["A1"].PutValue("Product1"); gridSheet.Cells["A2"].PutValue("Product2"); gridSheet.Cells["A3"].PutValue("Product3"); gridSheet.Cells["A4"].PutValue("Product4"); gridSheet.Cells["B1"].PutValue(100); gridSheet.Cells["B2"].PutValue(200); gridSheet.Cells["B3"].PutValue(300); gridSheet.Cells["B4"].PutValue(400); //Set the caption of the first two columns. gridSheet.SetColumnCaption(0, "Product Name"); gridSheet.SetColumnCaption(1, "Price"); //Set the column width of the first column. gridSheet.Cells.SetColumnWidth(0, 20); //Set the second column header's tip. gridSheet.SetColumnHeaderToolTip(1, "Unit Price of Products"); //Set the last cell so that scroll bars appear gridSheet.Cells["J30"].PutValue(""); } }
private void CreateColumnCaptions() { // ExStart:CustomizeColumnHeader // Accessing the worksheet that is currently active GridWorksheet workSheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; // Creates custom column header caption. workSheet.SetColumnCaption(0, "Product"); workSheet.SetColumnCaption(1, "Category"); workSheet.SetColumnCaption(2, "Price"); // ExEnd:CustomizeColumnHeader }
protected void Button1_Click(object sender, EventArgs e) { // Only showss 3 columns. GridWeb1.MaxColumn = 2; GridWorksheet workSheet = GridWeb1.WorkSheets[0]; GridCells cells = workSheet.Cells; // Creates Custom Header Caption. workSheet.SetColumnCaption(0, "Product"); workSheet.SetColumnCaption(1, "Category"); workSheet.SetColumnCaption(2, "Price"); workSheet.SetRowCaption(2, "row2"); // Put some values. cells["A1"].PutValue("Aniseed Syrup"); cells["A2"].PutValue("Boston Crab Meat"); cells["A3"].PutValue("Chang"); cells["B1"].PutValue("Condiments"); cells["B2"].PutValue("Seafood"); cells["B3"].PutValue("Beverages"); cells["C1"].PutValue(14.95); Aspose.Cells.GridWeb.GridTableItemStyle style = cells["C1"].Style; style.NumberType = (int)NumberType.Currency3; style.HorizontalAlign = HorizontalAlign.Right; cells["C1"].Style = style; cells["C2"].PutValue(24.99); cells["C2"].Style = style; cells["C3"].PutValue(49.95); cells["C3"].Style = style; // Adjusts column width. cells.SetColumnWidth(0, 20); cells.SetColumnWidth(1, 20); cells.SetColumnWidth(2, 20); }