// input Entry protection/validation data
    private void initData()
    {
        // Forces validation.
        //GridWeb1.ForceValidation = true;

        string path = Server.MapPath("~");

        path = path.Substring(0, path.LastIndexOf("\\"));
        string fileName = path + "\\File\\Input.xls";

        // Imports from a excel file.
        GridWeb1.ImportExcelFile(fileName);
        GridWorksheetCollection sheets = GridWeb1.WorkSheets;

        // Sets cell validation.
        GridValidationCollection gridValidationCollection = sheets[0].Validations;

        // Regular expression.
        GridValidation C5 = gridValidationCollection.Add();

        C5.AddACell("C5");
        //C5.Operator = OperatorType.BETWEEN;
        C5.ValidationType = GridValidationType.CustomExpression;
        C5.RegEx          = @"\d{6}";

        // Number.
        GridValidation C6 = gridValidationCollection.Add();

        C6.AddACell("C6");
        C6.ValidationType = GridValidationType.Decimal;

        // Integer.
        GridValidation C7 = gridValidationCollection.Add();

        C7.AddACell("C7");
        C7.ValidationType = GridValidationType.WholeNumber;

        // Date.
        GridValidation C8 = gridValidationCollection.Add();

        C8.AddACell("C8");
        C8.ValidationType = GridValidationType.Date;

        // DateTime
        GridValidation C9 = gridValidationCollection.Add();

        C9.AddACell("C9");
        C9.ValidationType = GridValidationType.DateTime;

        // List.
        GridValidation C10 = gridValidationCollection.Add();

        C10.AddACell("C10");
        C10.ValidationType = GridValidationType.List;
        StringCollection value = new StringCollection();

        value.Add("Fortran");
        value.Add("Pascal");
        value.Add("C++");
        value.Add("Visual Basic");
        value.Add("Java");
        value.Add("C#");
        C10.ValueList = value;
        value.Clear();

        // DropDownList.
        GridValidation C11 = gridValidationCollection.Add();

        C11.AddACell("C11");
        C11.ValidationType = GridValidationType.DropDownList;
        value.Add("Bachelor");
        value.Add("Master");
        value.Add("Doctor");
        C11.ValueList = value;

        // FreeList
        GridValidation C12 = gridValidationCollection.Add();

        C12.AddACell("C12");
        C12.ValidationType = GridValidationType.FreeList;
        value.Add("US");
        value.Add("Britain");
        value.Add("France");
        C12.ValueList = value;

        // Custom function
        GridValidation C13 = gridValidationCollection.Add();

        C13.AddACell("C13");
        C13.ValidationType           = GridValidationType.CustomFunction;
        C13.ClientValidationFunction = "myvalidation1";

        // CheckBox
        GridValidation C14 = gridValidationCollection.Add();

        C14.AddACell("C14");
        C14.ValidationType = GridValidationType.CheckBox;
    }
Example #2
0
    private void InitData()
    {
        // Gets the web application's path.
        string path = Server.MapPath("~");

        // Upper level.
        path = path.Substring(0, path.LastIndexOf("\\"));
        string fileName = path + "\\File\\Hyperlink.xls";

        // Clears datasheets first.
        GridWeb1.WorkSheets.Clear();
        // Imports from a excel file.
        GridWeb1.ImportExcelFile(fileName);
        GridHyperlinkCollection ghc = GridWeb1.WorkSheets[0].Hyperlinks;
        //Adds a text hyperlink that gos to Aspose site and opens in new window
        int           i           = ghc.Add("B1", "http://www.aspose.com");
        GridHyperlink linkOfText1 = ghc[i];

        linkOfText1.Target        = "_blank";
        linkOfText1.TextToDisplay = "Aspose site";
        linkOfText1.ScreenTip     = "Go to Aspose site and open in new window";

        ////Adds a text hyperlink that gos to Aspose site and opens in current window
        GridHyperlink linkOfText2 = ghc[ghc.Add("B2", "http://localhost:40056/grid/common/Pagination.aspx")];

        linkOfText2.TextToDisplay = "Paginatind sheet Demo";
        linkOfText2.Target        = "_self";
        linkOfText2.ScreenTip     = "Go to Aspose site and open in current window";

        //Adds a text hyperlink that gos to Aspose site and opens in top window
        GridHyperlink linkOfText3 = ghc[ghc.Add("B3", "http://www.aspose.com/categories/.net-components/aspose.cells-for-.net/default.aspx")];

        linkOfText3.TextToDisplay = "Aspose.Cells.GridWeb Product";
        linkOfText3.Target        = "_top";
        linkOfText3.ScreenTip     = "Go to Aspose site and open in top window";

        //Adds a text hyperlink that gos to Aspose site and opens in parent window
        GridHyperlink linkOfText4 = ghc[ghc.Add("B4", "http://www.aspose.com/Community/Forums/258/ShowForum.aspx")];

        linkOfText4.TextToDisplay = "Aspose.Cells.GridWeb Forums";
        linkOfText4.Target        = "_parent";
        linkOfText4.ScreenTip     = "Go to Aspose site and open in parent window";

        //Adds a image hyperlink that gos to Aspose site and opens in current window
        GridHyperlink linkOfImage1 = ghc[ghc.Add("B6", "http://www.aspose.com")];

        linkOfImage1.ImageURL  = "../../Images/Aspose.Banner.gif";
        linkOfImage1.Target    = "_blank";
        linkOfImage1.ScreenTip = "Go to Aspose site and open in new window";

        //Adds a image hyperlink that gos to Aspose.Cells.GridWeb site and opens in new window
        GridHyperlink linkOfImage2 = ghc[ghc.Add("B7", "http://www.aspose.com/categories/.net-components/aspose.cells-for-.net/default.aspx")];

        linkOfImage2.ImageURL  = "../../Images/Aspose.Grid.gif";
        linkOfImage1.Target    = "_blank";
        linkOfImage2.ScreenTip = "Go to Aspose site and open in new window";


        //Adds a CellImage
        GridHyperlink image = ghc[ghc.Add("B8", "")];

        image.ImageURL = "../../Images/Aspose.Grid.gif";
        //image.ActionType = HyperlinkActionType.CellCommand;
        image.ScreenTip = "A simple CellImage.";
        GridWeb1.WorkSheets[0].Cells["A8"].PutValue("Creates a CellImage:");
        GridWeb1.WorkSheets[0].Cells.SetRowHeight(7, 100);

        //Picture pi = GridWeb1.WebWorksheets[0].Pictures.AddPicture("B8");
        //pi.Image = "";

        GridCells cells = GridWeb1.WorkSheets[1].Cells;
        GridValidationCollection gvc        = GridWeb1.WorkSheets[1].Validations;
        GridValidation           validation = gvc.Add("B13");

        validation.ValidationType = GridValidationType.DropDownList;
        StringCollection value = new StringCollection();

        value.Add("1996");
        value.Add("1997");
        value.Add("1998");
        validation.ValueList = value;
        cells["B13"].PutValue("1996");

        //Adds a cell command hyperlink
        GridHyperlink linkOfCellCommand1 = ghc[ghc.Add("C13", "")];

        linkOfCellCommand1.Command   = "Year";
        linkOfCellCommand1.ScreenTip = "Summarizes Sales by Year";
        linkOfCellCommand1.ImageURL  = "../../Images/button1.bmp";

        GridValidation validationB14 = gvc.Add("B14");

        validationB14.ValidationType = GridValidationType.DropDownList;
        validationB14.Formula1       = "1,2,3,4";
        cells["B14"].PutValue("1");

        //Adds a cell command hyperlink
        GridHyperlink linkOfCellCommand2 = ghc[ghc.Add("C14", "")];

        linkOfCellCommand2.Command   = "Quarter";
        linkOfCellCommand2.ScreenTip = "Summarizes Sales by Quater";
        linkOfCellCommand2.ImageURL  = "../../Images/button2.bmp";
    }