Ejemplo n.º 1
0
        private void InitData()
        {
            // Gets the web application's path.
            string path = (this.Master as Site).GetDataDir();

            string fileName = path + "\\Worksheets\\Sort.xls";

            // Imports from an excel file.
            GridWeb1.ImportExcelFile(fileName);

            // Creates sorting header style.
            GridTableItemStyle itemStyle = new GridTableItemStyle();

            itemStyle.BorderStyle     = BorderStyle.Outset;
            itemStyle.BorderWidth     = 2;
            itemStyle.BorderColor     = Color.White;
            itemStyle.BackColor       = Color.Silver;
            itemStyle.HorizontalAlign = HorizontalAlign.Center;
            itemStyle.VerticalAlign   = VerticalAlign.Middle;

            // Creates Hyperlinks Sheet1. Sorts from top to bottom orientation.
            GridHyperlink cellcmd;
            GridCells     cells0 = GridWeb1.WorkSheets[0].Cells;

            cells0["A1"].CopyStyle(itemStyle);
            GridHyperlinkCollection ghc = GridWeb1.WorkSheets[0].Hyperlinks;
            int i = ghc.Add("A1", "");

            cellcmd               = ghc[i];
            cellcmd.Command       = "A1";
            cellcmd.ScreenTip     = "Sorts Descending";
            cellcmd.TextToDisplay = "OrderId";

            cells0["B1"].CopyStyle(itemStyle);
            cellcmd               = ghc[ghc.Add("B1", "")];
            cellcmd.Command       = "B1";
            cellcmd.ScreenTip     = "Sorts Ascending";
            cellcmd.TextToDisplay = "Sales Amout";

            cells0["C1"].CopyStyle(itemStyle);
            cellcmd               = ghc[ghc.Add("C1", "")];
            cellcmd.Command       = "C1";
            cellcmd.ScreenTip     = "Sorts Descending";
            cellcmd.TextToDisplay = "Percent of Saler's Total";

            cells0["D1"].CopyStyle(itemStyle);
            cellcmd = ghc[ghc.Add("D1", "")];

            cellcmd.Command       = "D1";
            cellcmd.ScreenTip     = "Sorts Ascending";
            cellcmd.TextToDisplay = "Percent of Country Total";

            // Creates Hyperlinks Sheet2. Sorts from left to right orientation.
            GridCells cells1             = GridWeb1.WorkSheets[1].Cells;
            GridHyperlinkCollection ghcb = GridWeb1.WorkSheets[1].Hyperlinks;

            cells1["A1"].CopyStyle(itemStyle);
            cellcmd = ghcb[ghcb.Add("A1", "")];

            cellcmd.Command       = "1A1";
            cellcmd.ScreenTip     = "Sorts Ascending";
            cellcmd.TextToDisplay = "Product";

            cells1["A2"].CopyStyle(itemStyle);
            cellcmd = ghcb[ghcb.Add("A2", "")];

            cellcmd.Command       = "1A2";
            cellcmd.ScreenTip     = "Sorts Ascending";
            cellcmd.TextToDisplay = "Category";

            cells1["A3"].CopyStyle(itemStyle);
            cellcmd = ghcb[ghcb.Add("A3", "")];

            cellcmd.Command       = "1A3";
            cellcmd.ScreenTip     = "Sorts Ascending";
            cellcmd.TextToDisplay = "Package";

            cells1["A4"].CopyStyle(itemStyle);
            cellcmd = ghcb[ghcb.Add("A4", "")];

            cellcmd.Command       = "1A4";
            cellcmd.ScreenTip     = "Sorts Ascending";
            cellcmd.TextToDisplay = "Quantity";
        }
Ejemplo n.º 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";
    }