// Import C:\Program Files\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office14\Microsoft.Office.Interop.Excel.dll
// Import C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Drawing.dll
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading;namespace InteropExcelChart
{
    class Program
    {
        static void Main(string[] args)
        {
            Microsoft.Office.Interop.Excel.Application excel =
                new Microsoft.Office.Interop.Excel.ApplicationClass();
            var book = excel.Workbooks.Add();
            excel.Visible = true;            var sheet = book.Sheets.Add() as Microsoft.Office.Interop.Excel.Worksheet;
            // add link
            var range = sheet.Range["A1"];
            range.Value2 = "Google";
            sheet.Hyperlinks.Add(range, "http://g.cn");
            //
            Thread.Sleep(5000);            book.Close(false);
            excel.Quit();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(book);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
        }
    }
}

解决方案 »

  1.   

    补充一下,以上代码是C#4.0,Excel 2010,如果你的环境不一样可能需要少量修改代码。
      

  2.   

    Worksheet ThisSheet = new Worksheet();
    ThisSheet = (Worksheet)ThisWorkBook.ActiveSheet;
    Range rn = (Range)ThisSheet.Cells[1, 1];
    rn.Hyperlinks.Add(rn, "", "", missing, "");
      

  3.   

    public void AddHyperLink(Microsoft.Office.Interop.Excel._Worksheet CurSheet, object objCell, string strAddress, string strTip, string strText)
            {
                CurSheet.Hyperlinks.Add(CurSheet.get_Range(objCell, objCell), strAddress, mValue, strTip, strText);
            }