彩票走势图

用Aspose.Cells在工作表中添加图片超链接

原创|其它|编辑:郝浩|2012-09-03 14:36:33.000|阅读 2876 次

概述:Aspose.Cells是怎样为电子表格添加图片并为图片设置超链接的呢?答案就在这里。本文为大家提供了最简单的代码来实现图片链接设置。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

Aspose.Cells是怎样为电子表格添加图片并为图片设置超链接的呢?答案就在这里。本文为大家提供了最简单的代码来实现图片链接设置。OK,下面就让慧都小编来和大家一起学习吧:

[C#]

 //Instantiate a new workbook
Workbook workbook = new Workbook();
//Get the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
//Insert a string value to a cell
worksheet.Cells["C2"].PutValue("Image Hyperlink");
//Set the 4th row height
worksheet.Cells.SetRowHeight(3, 100);
//Set the C column width
worksheet.Cells.SetColumnWidth(2, 21);
//Add a picture to the C4 cell
int index = worksheet.Pictures.Add(3, 2, 4, 3, "f:\\test\\school.jpg");
//Get the picture object
Aspose.Cells.Drawing.Picture pic = worksheet.Pictures[index];
//Set the placement type
pic.Placement = PlacementType.FreeFloating;
//Add an image hyperlink
Aspose.Cells.Hyperlink hlink = pic.AddHyperlink("");
//Specify the screen tip
hlink.ScreenTip = "Click to go to Aspose site";
//Save the excel file
workbook.Save("f:\\test\\ImageHyperlink.xls");


[VB]

 'Instantiate a new workbook
Dim workbook As New Workbook()
'Get the first worksheet
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Insert a string value to a cell
worksheet.Cells("C2").PutValue("Image Hyperlink")
'Set the 4th row height
worksheet.Cells.SetRowHeight(3, 100)
'Set the C column width
worksheet.Cells.SetColumnWidth(2, 21)
'Add a picture to the C4 cell
Dim index As Integer = worksheet.Pictures.Add(3, 2, 4, 3, "f:\test\school.jpg")
'Get the picture object
Dim pic As Aspose.Cells.Drawing.Picture = worksheet.Pictures(index)
'Set the placement type
pic.Placement = PlacementType.FreeFloating
'Add an image hyperlink
Dim hlink As Aspose.Cells.Hyperlink = pic.AddHyperlink("")
'Specify the screen tip
hlink.ScreenTip = "Click to go to Aspose site"
'Save the excel file
workbook.Save("f:\test\ImageHyperlink.xls")

简单吧!生成的文件效果图如下:

用Aspose.cells在工作表中添加图片超链接


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@capbkgr.cn

文章转载自:本站原创

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP