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

btnApplyNumberFormats_Click() protected method

protected btnApplyNumberFormats_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        protected void btnApplyNumberFormats_Click(object sender, EventArgs e)
        {
            // ExStart:ApplyNumberFormats
            // Accessing the reference of the worksheet that is currently active
            GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];

            sheet.Cells.Clear();
            
            sheet.Cells.SetColumnWidth(0, 50);
            sheet.Cells.SetRowHeight(0, 40);

            // Putting values to cells
            sheet.Cells["A1"].PutValue("Currency1 Number Format");
            sheet.Cells["A2"].PutValue("Custom Number Format");
            sheet.Cells["B1"].PutValue(7800);
            sheet.Cells["B2"].PutValue(2500);

            // Setting the number format of "B1" cell to Currency1
            sheet.Cells["B1"].SetNumberType((int)NumberType.Currency1);
        
            // Setting the custom number format of "B2" cell
            sheet.Cells["B2"].SetCustom("#,##0.0000");
            // ExEnd:ApplyNumberFormats
        }
    }