HyperlinkCollection.Add

Add(int, int, int, int, string)

Adds a hyperlink to a specified cell or a range of cells.

public int Add(int firstRow, int firstColumn, int totalRows, int totalColumns, string address)
ParameterTypeDescription
firstRowInt32First row of the hyperlink range.
firstColumnInt32First column of the hyperlink range.
totalRowsInt32Number of rows in this hyperlink range.
totalColumnsInt32Number of columns of this hyperlink range.
addressStringAddress of the hyperlink.

Return Value

Hyperlink object index.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class HyperlinkCollectionMethodAddWithInt32Int32Int32Int32StringDemo
    {
        public static void Run()
        {
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Add hyperlink using row/column coordinates and dimensions
            worksheet.Hyperlinks.Add(0, 0, 1, 1, "http://www.aspose.com");
            worksheet.Hyperlinks.Add(1, 0, 1, 1, "c:\\book1.xls");
            
            workbook.Save("HyperlinkDemo.xlsx");
        }
    }
}

See Also


Add(string, int, int, string)

Adds a hyperlink to a specified cell or a range of cells.

public int Add(string cellName, int totalRows, int totalColumns, string address)
ParameterTypeDescription
cellNameStringCell name.
totalRowsInt32Number of rows in this hyperlink range.
totalColumnsInt32Number of columns of this hyperlink range.
addressStringAddress of the hyperlink.

Return Value

Hyperlink object index.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class HyperlinkCollectionMethodAddWithStringInt32Int32StringDemo
    {
        public static void Run()
        {
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            HyperlinkCollection hyperlinks = worksheet.Hyperlinks;

            // Add hyperlink to cell A1 with address "www.aspose.com"
            hyperlinks.Add("A1", 1, 1, "www.aspose.com");
            
            // Display the hyperlink address
            Console.WriteLine("Hyperlink Address: " + worksheet.Cells["A1"].StringValue);
            
            // Change the display text
            worksheet.Cells["A1"].PutValue("Click Here");
            Console.WriteLine("Display Text: " + hyperlinks[0].TextToDisplay);
            
            workbook.Save("HyperlinkExample.xlsx");
        }
    }
}

See Also


Add(string, string, string, string, string)

Adds a hyperlink to a specified cell or a range of cells.

public int Add(string startCellName, string endCellName, string address, string textToDisplay, 
    string screenTip)
ParameterTypeDescription
startCellNameStringThe top-left cell of the range.
endCellNameStringThe bottom-right cell of the range.
addressStringAddress of the hyperlink.
textToDisplayStringThe text to be displayed for the specified hyperlink.
screenTipStringThe screenTip text for the specified hyperlink.

Return Value

Hyperlink object index.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class HyperlinkCollectionMethodAddWithStringStringStringStringStringDemo
    {
        public static void Run()
        {
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            HyperlinkCollection hyperlinks = worksheet.Hyperlinks;

            // Demonstrate Add method with (String, String, String, String, String) parameters
            hyperlinks.Add("D1", "D2", "http://www.display.com", "Click Here", "Go to Display");

            workbook.Save("HyperlinkCollectionExample.xlsx");
        }
    }
}

See Also