Aspose.Cells.GridWeb.Examples.CSharp.Worksheets.AddWorksheets.btnAddWorksheets_Click C# (CSharp) Method

btnAddWorksheets_Click() protected method

protected btnAddWorksheets_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        protected void btnAddWorksheets_Click(object sender, EventArgs e)
        {
            // ExStart:AddWorksheetWithoutName
            // Adding a worksheet to GridWeb without specifying name
            int sheetIndex = GridWeb1.WorkSheets.Add();
            GridWorksheet sheet = GridWeb1.WorkSheets[sheetIndex];           
            Label1.Text = sheet.Name + " worksheet is added at index " + sheetIndex + ". <br/>";
            // ExEnd:AddWorksheetWithoutName

			sheet.Cells["A1"].PutValue("Worksheet with Default Name");
			 
            // ExStart:AddWorksheetWithName
            //Adding a worksheet to GridWeb with a specified name
            if (GridWeb1.WorkSheets["Teachers"] == null)
            {
                GridWorksheet sheet1 = GridWeb1.WorkSheets.Add("Teachers");
                Label1.Text += sheet1.Name + " worksheet is added at index " + sheet1.Index + ". <br/>";
            }
            // ExEnd:AddWorksheetWithName
			
			sheet = GridWeb1.WorkSheets["Teachers"];
            sheet.Cells["A1"].PutValue("Worksheet with Specified Name");
        }
    }