110,499
社区成员
发帖
与我相关
我的任务
分享
// 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);
}
}
}