protected void btnAddListValidation_Click(object sender, EventArgs e)
        {
            // ExStart:AddListValidation
            // Accessing the cells collection of the worksheet that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing "B1" cell
            WebCell cell = sheet.Cells[0, 1];

            // Putting value to "B1" cell
            cell.PutValue("Select Course:");

            // Accessing "C1" cell
            cell = sheet.Cells[0, 2];

            // Creating List validation for the "C1" cell
            cell.CreateValidation(ValidationType.List, true);

            // Adding values to List validation
            cell.Validation.ValueList.Add("Fortran");
            cell.Validation.ValueList.Add("Pascal");
            cell.Validation.ValueList.Add("C++");
            cell.Validation.ValueList.Add("Visual Basic");
            cell.Validation.ValueList.Add("Java");
            cell.Validation.ValueList.Add("C#");
            // ExEnd:AddListValidation
        }
Beispiel #2
0
        private void InitGridWeb()
        {
            // ExStart:WriteClientSideScript
            // Assigning the name of JavaScript function to OnSubmitClientFunction property of GridWeb
            GridWeb1.OnSubmitClientFunction = "ConfirmFunction";

            // Assigning the name of JavaScript function to OnValidationErrorClientFunction property of GridWeb
            GridWeb1.OnValidationErrorClientFunction = "ValidationErrorFunction";

            // Accessing the cells collection of the worksheet that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing "B1" cell
            WebCell cell = sheet.Cells[0, 1];

            // Putting value to "B1" cell
            cell.PutValue("Date (yyyy-mm-dd):");

            // Accessing "C1" cell
            cell = sheet.Cells[0, 2];

            // Creating a custom expression validation for the "C1" cell
            cell.CreateValidation(ValidationType.CustomExpression, true);

            // Setting regular expression for the validation to accept dates in yyyy-mm-dd format
            cell.Validation.RegEx = @"\d{4}-\d{2}-\d{2}";
            // ExEnd:WriteClientSideScript
        }
Beispiel #3
0
        protected void btnAddCustomValidation_Click(object sender, EventArgs e)
        {
            // ExStart:AddCustomValidation
            // Accessing the cells collection of the worksheet that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing "B1" cell
            WebCell cell = sheet.Cells[0, 1];

            // Putting value to "B1" cell
            cell.PutValue("Date (yyyy-mm-dd):");

            // Accessing "C1" cell
            cell = sheet.Cells[0, 2];

            // Creating a custom expression validation for the "C1" cell
            cell.CreateValidation(ValidationType.CustomExpression, true);

            // Setting regular expression for the validation to accept dates in yyyy-mm-dd format
            cell.Validation.RegEx = @"\d{4}-\d{2}-\d{2}";
            // ExEnd:AddCustomValidation

            sheet.Cells.SetColumnWidth(1, new Unit(100, UnitType.Point));

            // Assigning the name of JavaScript function to OnValidationErrorClientFunction property of GridWeb
            GridWeb1.OnValidationErrorClientFunction = "ValidationErrorFunction";
        }
        protected void btnApplyBorderStyles_Click(object sender, EventArgs e)
        {
            // ExStart:ApplyBorderStyles
            // Accessing the reference of the worksheet that is currently active and resize first row and column
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            sheet.Cells.Clear();

            sheet.Cells.SetColumnWidth(0, new Unit(200, UnitType.Point));
            sheet.Cells.SetRowHeight(0, new Unit(50, UnitType.Point));

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

            Aspose.Cells.GridWeb.TableItemStyle style = cell.GetStyle();

            // Setting the border style to Solid
            style.BorderStyle = BorderStyle.Solid;

            // Setting the border width to 2 pixels
            style.BorderWidth = new Unit(2, UnitType.Pixel);

            // Setting the border color to Blue
            style.BorderColor = Color.Blue;

            // Set the cell style
            cell.SetStyle(style);
            // ExEnd:ApplyBorderStyles
        }
        private void AccessCellByRowColumnIndex()
        {
            // ExStart:AccessCellByRowColumnIndex
            // Accessing the worksheet of the Grid that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing "B1" cell of the worksheet using its row and column indices
            WebCell cell = sheet.Cells[0, 1];

            // Display cell name and value
            Label1.Text += "Cell Value of " + cell.Name + " is " + cell.StringValue + "<br/>";
            // ExEnd:AccessCellByRowColumnIndex
        }
        private void AccessCellByName()
        {
            // ExStart:AccessCellByName
            // Accessing the worksheet of the Grid that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing "B1" cell of the worksheet
            WebCell cell = sheet.Cells["A1"];

            // Display cell name and value
            Label1.Text += "Cell Value of " + cell.Name + " is " + cell.StringValue + "<br/>";
            // ExEnd:AccessCellByName
        }
Beispiel #7
0
        private void AddDoubleValue()
        {
            // ExStart:AddCellDoubleValue
            // Accessing the worksheet of the Grid that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing "B5" cell of the worksheet
            WebCell cell = sheet.Cells["B5"];

            // Putting a numeric value as string in "B5" cell that will be converted to a suitable data type automatically
            cell.PutValue("19.4", true);
            // ExEnd:AddCellDoubleValue
        }
Beispiel #8
0
        private void AddIntValue()
        {
            // ExStart:AddCellIntValue
            // Accessing the worksheet of the Grid that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing "B3" cell of the worksheet
            WebCell cell = sheet.Cells["B3"];

            // Putting a value in "B3" cell
            cell.PutValue(30);
            // ExEnd:AddCellIntValue
        }
Beispiel #9
0
        private void AddStringValue()
        {
            // ExStart:AddCellStringValue
            // Accessing the worksheet of the Grid that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing "B1" cell of the worksheet
            WebCell cell = sheet.Cells["B1"];

            // Accessing & modifying the string value of "B1" cell
            cell.StringValue = "Hello Aspose.Grid";
            // ExEnd:AddCellStringValue
        }
        protected void btnUpdateHyperlinks_Click(object sender, EventArgs e)
        {
            // ExStart:AccessHyperlinks
            // Accessing the reference of the worksheet that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing a specific cell that contains hyperlink
            WebCell cell = sheet.Cells["B1"];

            // Accessing the hyperlink from the specific cell
            Hyperlink link = sheet.Hyperlinks.GetHyperlink(cell);

            if (link != null)
            {
                // Modifying the text and URL of hyperlink
                link.Text = "Aspose.Blogs";
                link.Url  = "http://www.aspose.com/Community/Blogs";
            }
            // ExEnd:AccessHyperlinks
        }
        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
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            sheet.Cells.Clear();

            sheet.Cells.SetColumnWidth(0, new Unit(200, UnitType.Point));
            sheet.Cells.SetRowHeight(0, new Unit(50, UnitType.Point));
            // Accessing a specific cell of the worksheet
            WebCell cell = sheet.Cells["A1"];

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

            Aspose.Cells.GridWeb.TableItemStyle style = cell.GetStyle();

            // Setting the font size to 12 points
            style.Font.Size = new FontUnit("12pt");

            // Setting font style to Bold
            style.Font.Bold = true;

            // Setting foreground color of font to Blue
            style.ForeColor = Color.Blue;

            // Setting background color of font to Aqua
            style.BackColor = Color.Aqua;

            // Setting the horizontal alignment of font to Center
            style.HorizontalAlign = HorizontalAlign.Center;

            // Set the cell style
            cell.SetStyle(style);
            // ExEnd:ApplyFontStyles
        }
Beispiel #12
0
        protected void btnAddDropDownListValidation_Click(object sender, EventArgs e)
        {
            // ExStart:AddDropDownListValidation
            // Accessing the cells collection of the worksheet that is currently active
            WebWorksheet sheet = GridWeb1.WebWorksheets[GridWeb1.ActiveSheetIndex];

            // Accessing "B1" cell
            WebCell cell = sheet.Cells[0, 1];

            // Putting value to "B1" cell
            cell.PutValue("Select Degree:");

            // Accessing "C1" cell
            cell = sheet.Cells[0, 2];

            // Creating DropDownList validation for the "C1" cell
            cell.CreateValidation(ValidationType.DropDownList, true);

            // Adding values to DropDownList validation
            cell.Validation.ValueList.Add("Bachelor");
            cell.Validation.ValueList.Add("Master");
            cell.Validation.ValueList.Add("Doctor");
            // ExEnd:AddDropDownListValidation
        }
        internal static WebControl GetWebControlFromIContol(IControl aControl, Browser aBrowser, Locator aLocator, ControlType aConrolType)
        {
            WebControl aWebControl = null;

            if (aConrolType == ControlType.Button)
            {
                WebButton aWebButton = new WebButton(aBrowser, aLocator);
                aWebButton.Control = aControl;
                aWebControl        = aWebButton;
            }

            if (aConrolType == ControlType.EditBox)
            {
                WebEditBox aWebEditBox = new WebEditBox(aBrowser, aLocator);
                aWebEditBox.Control = aControl;
                aWebControl         = aWebEditBox;
            }

            if (aConrolType == ControlType.Custom)
            {
                aWebControl         = new WebControl(aBrowser, aLocator);
                aWebControl.Control = aControl;
                //aWebControl = aWebEditBox;
            }
            if (aConrolType == ControlType.Calender)
            {
                WebCalender aWebCalender = new WebCalender(aBrowser, aLocator);
                aWebCalender.Control = aControl;
                aWebControl          = aWebCalender;
            }

            if (aConrolType == ControlType.ComboBox)
            {
                WebComboBox aWebComboBox = new WebComboBox(aBrowser, aLocator);
                aWebComboBox.Control = aControl;
                aWebControl          = aWebComboBox;
            }

            if (aConrolType == ControlType.CheckBox)
            {
                WebCheckBox aWebCheckBox = new WebCheckBox(aBrowser, aLocator);
                aWebCheckBox.Control = aControl;
                aWebControl          = aWebCheckBox;
            }

            if (aConrolType == ControlType.Dialog)
            {
                WebDialog aWebDialog = new WebDialog(aBrowser, aLocator);
                aWebDialog.Control = aControl;
                aWebControl        = aWebDialog;
            }

            if (aConrolType == ControlType.Frame)
            {
                WebFrame aWebFrame = new WebFrame(aBrowser, aLocator);
                aWebFrame.Control = aControl;
                aWebControl       = aWebFrame;
            }

            if (aConrolType == ControlType.Image)
            {
                WebImage aWebImage = new WebImage(aBrowser, aLocator);
                aWebImage.Control = aControl;
                aWebControl       = aWebImage;
            }

            if (aConrolType == ControlType.Label)
            {
                WebLabel aWebLabel = new WebLabel(aBrowser, aLocator);
                aWebLabel.Control = aControl;
                aWebControl       = aWebLabel;
            }

            if (aConrolType == ControlType.Link)
            {
                WebLink aWebLink = new WebLink(aBrowser, aLocator);
                aWebLink.Control = aControl;
                aWebControl      = aWebLink;
            }

            if (aConrolType == ControlType.ListBox)
            {
                WebListBox aWebListBox = new WebListBox(aBrowser, aLocator);
                aWebListBox.Control = aControl;
                aWebControl         = aWebListBox;
            }

            if (aConrolType == ControlType.Page)
            {
                WebPage aWebPage = new WebPage(aBrowser, aLocator);
                aWebPage.Control = aControl;
                aWebControl      = aWebPage;
            }

            if (aConrolType == ControlType.RadioButton)
            {
                WebRadioButton aWebRadioButton = new WebRadioButton(aBrowser, aLocator);
                aWebRadioButton.Control = aControl;
                aWebControl             = aWebRadioButton;
            }

            if (aConrolType == ControlType.SpanArea)
            {
                WebSpanArea aWebSpanArea = new WebSpanArea(aBrowser, aLocator);
                aWebSpanArea.Control = aControl;
                aWebControl          = aWebSpanArea;
            }

            if (aConrolType == ControlType.WebTable)
            {
                WebTable aWebTable = new WebTable(aBrowser, aLocator);
                aWebTable.Control = aControl;
                aWebControl       = aWebTable;
            }

            if (aConrolType == ControlType.WebRow)
            {
                WebRow aWebRow = new WebRow(aBrowser, aLocator);
                aWebRow.Control = aControl;
                aWebControl     = aWebRow;
            }

            if (aConrolType == ControlType.WebCell)
            {
                WebCell aWebCell = new WebCell(aBrowser, aLocator);
                aWebCell.Control = aControl;
                aWebControl      = aWebCell;
            }


            return(aWebControl);
        }