private void AddImageHyPerlinks()
        {
            // Accessing the reference of the worksheet that is currently active
            GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];

            // Adding hyperlink to the worksheet
            int           linkIndex = sheet.Hyperlinks.Add("B5", "http://www.aspose.com");
            GridHyperlink link1     = sheet.Hyperlinks[linkIndex];

            link1.Target = "_blank";

            // Setting URL of the image that will be displayed as hyperlink
            link1.ImageURL = "../Images/Aspose.Banner.gif";

            // Setting tool tip of the hyperlink
            link1.ScreenTip = "Open Aspose Web Site in new window";

            // Resize the row to display image nicely
            sheet.Cells.SetRowHeight(4, 40);

            // Adding hyperlink to the worksheet
            linkIndex = sheet.Hyperlinks.Add("B6", "http://www.aspose.com/docs/display/cellsnet/Aspose.Cells.GridWeb");
            GridHyperlink link2 = sheet.Hyperlinks[linkIndex];

            link2.Target = "_blank";

            // Setting URL of the image that will be displayed as hyperlink
            link2.ImageURL = "../Images/Aspose.Grid.gif";

            // Setting tool tip of the hyperlink
            link2.ScreenTip = "Open Aspose.Grid Docs in new window";
        }
        private void AddTextHyperlinks()
        {
            // Accessing the reference of the worksheet that is currently active
            GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];

            // Adds a text hyperlink that gos to Aspose site and opens in new window
            int           linkIndex = sheet.Hyperlinks.Add("B1", "http://www.aspose.com");
            GridHyperlink link1     = sheet.Hyperlinks[linkIndex];

            link1.Target = "_blank";

            // Setting text of the hyperlink
            link1.TextToDisplay = "Aspose";

            // Setting tool tip of the hyperlink
            link1.ScreenTip = "Open Aspose Web Site in new window";

            // Adding hyperlink to the worksheet to open in parent window
            linkIndex = sheet.Hyperlinks.Add("B2", "http://www.aspose.com/docs/display/cellsnet/Aspose.Cells.GridWeb");
            GridHyperlink link2 = sheet.Hyperlinks[linkIndex];

            link2.Target = "_parent";

            // Setting text of the hyperlink
            link2.TextToDisplay = "Aspose.Grid Docs";

            // Setting tool tip of the hyperlink
            link2.ScreenTip = "Open Aspose.Grid Docs in parent window";
        }
예제 #3
0
        private void AddCellCommandHyperlinks()
        {
            // ExStart:AddCellCommandHyperlinks
            // Accessing the reference of the worksheet that is currently active
            GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];

            // Adding hyperlink to the worksheet
            int           linkIndex = sheet.Hyperlinks.Add("B8", "");
            GridHyperlink link1     = sheet.Hyperlinks[linkIndex];

            // Setting the cell command, tool tip and image URL for the hyperlink
            link1.Command   = "Click";
            link1.ScreenTip = "Click Here";
            link1.ImageURL  = "../Images/button.jpg";

            // Resize the row to display image nicely
            sheet.Cells.SetRowHeight(7, 30);
            // ExEnd:AddCellCommandHyperlinks
        }
        protected void btnUpdateHyperlinks_Click(object sender, EventArgs e)
        {
            // ExStart:AccessHyperlinks
            // Accessing the reference of the worksheet that is currently active
            GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];

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

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

            if (link != null)
            {
                // Modifying the text and URL of hyperlink
                link.TextToDisplay = "Aspose.Blogs";
                link.Address       = "http://www.aspose.com/Community/Blogs";
            }
            // ExEnd:AccessHyperlinks
        }
        protected void btnAccessCellHyperlink_Click(object sender, EventArgs e)
        {
            // ExStart:AccessHyperlink
            // Access first worksheet of gridweb and cell A1
            GridWorksheet sheet  = GridWeb1.WorkSheets[0];
            GridCell      cellA1 = sheet.Cells["A1"];

            // Access hyperlink of cell A1 if it contains any
            GridHyperlink cellHyperlink = sheet.Hyperlinks.GetHyperlink(cellA1);

            if (cellHyperlink == null)
            {
                Label1.Text = "Cell A1 does not have any hyperlink";
            }
            else
            {
                // Access hyperlink properties e.g. address
                string hyperlinkAddress = cellHyperlink.Address;
                Label1.Text = "Address of hyperlink in cell A1 :" + hyperlinkAddress;
            }
            // ExEnd:AccessHyperlink
        }
예제 #6
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";
    }