protected void btnCreate_Click(object sender, System.EventArgs e)
        {
            // Fill web worksheet object
            WebWorksheet sheet = GridWeb1.WebWorksheets[0];

            // Removes the created subtotal first.
            sheet.RemoveSubtotal();

            // Creates the subtotal.
            int groupByIndex;

            if (ddlSort.SelectedItem.Value == "CategoryName")
            {
                groupByIndex = 1;
            }
            else
            {
                groupByIndex = 2;
            }

            // Creates GrandTotal and Subtotal style.
            Aspose.Cells.GridWeb.TableItemStyle grandStyle = new Aspose.Cells.GridWeb.TableItemStyle();
            grandStyle.BackColor = Color.Gray;
            grandStyle.ForeColor = Color.Black;
            Aspose.Cells.GridWeb.TableItemStyle subtotalStyle = new Aspose.Cells.GridWeb.TableItemStyle();
            subtotalStyle.BackColor = Color.SkyBlue;
            subtotalStyle.ForeColor = Color.Black;

            // ExStart:CreateSubTotal
            sheet.CreateSubtotal(0, sheet.Cells.MaxRow, groupByIndex, (SubtotalFunction)System.Enum.Parse(typeof(SubtotalFunction), ddlFunction.SelectedItem.Value), new int[] { 1, 2, 3, 4, 5 }
                                 , ddlFunction.SelectedItem.Text, grandStyle, subtotalStyle, NumberType.General, null);
            // ExEnd:CreateSubTotal
        }