Aspose.Cells.GridWeb.Examples.CSharp.Cells.FormatCells.btnApplyFontStyles_Click C# (CSharp) Method

btnApplyFontStyles_Click() protected method

protected btnApplyFontStyles_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        protected void btnApplyFontStyles_Click(object sender, EventArgs e)
        {         
            // ExStart:ApplyFontStyles
            // Accessing the reference of the worksheet that is currently active and resize first row and column
            GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
            sheet.Cells.Clear();
            sheet.Cells.SetColumnWidth(0, 50);
            sheet.Cells.SetRowHeight(0, 40);

            // Accessing a specific cell of the worksheet
            GridCell cell = sheet.Cells["A1"];

            // Inserting a value in cell A1
            cell.PutValue("Aspose.Cells.GridWeb");
           
            var style = cell.Style;

            // Setting font, color and alignment of cell
            style.Font.Size = new FontUnit("12pt");
            style.Font.Bold = true;
            style.ForeColor = Color.Blue;
            style.BackColor = Color.Aqua;
            style.HorizontalAlign = HorizontalAlign.Center;                        

            // Set the cell style
            cell.CopyStyle(style);
            sheet.AutoFitColumn(0);
            // ExEnd:ApplyFontStyles           
        }