控件中国网现已改版,您看到的是老版本网站的镜像,系统正在为您跳转到新网站首页,请稍候.......
中国最专业的商业控件资讯网产品咨询电话:023-67870900 023-67871946
产品咨询EMAIL:SALES@COMPONENTCN.COM

Aspose.Cells实现添加图片到单元格注释里

作者:ComponentCN 出处:ComponentCN 2014年05月14日 阅读:

Aspose.Cells实现添加图片到单元格注释里

Aspose.Cells是一款功能强大的Excel电子数据表格控件,不需要电脑安装Excel的情况下实现对Excel文件的各种操作,下面我们介绍了如何使用该产品通过代码为单元格添加图片注释。

[C#]
//Instantiate a Workbook
Workbook workbook = new Workbook();

//Get a reference of comments collection with the first sheet
CommentCollection comments = workbook.Worksheets[0].Comments;

//Add a comment to cell A1
int commentIndex = comments.Add(0, 0);
Comment comment = comments[commentIndex];
comment.Note = "First note.";
comment.Font.Name = "Times New Roman";

//Load an image into stream
Bitmap bmp = new Bitmap("e:\\test\\school.jpg");
MemoryStream ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

//Set image data to the shape associated with the comment
comment.CommentShape.FillFormat.ImageData = ms.ToArray();

//Save the workbook
workbook.Save(@"e:\test2\commentwithpicture1.xlsx", Aspose.Cells.SaveFormat.Xlsx);

[VB]

'Instantiate a Workbook
Dim workbook As New Workbook()

'Get a reference of comments collection with the first sheet
Dim comments As CommentCollection = workbook.Worksheets(0).Comments

'Add a comment to cell A1
Dim commentIndex As Integer = comments.Add(0, 0)
Dim comment As Comment = comments(commentIndex)
comment.Note = "First note."
comment.Font.Name = "Times New Roman"

'Load an image into stream
Dim bmp As New Bitmap("e:\test\school.jpg")
Dim ms As New MemoryStream()
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png)

'Set image data to the shape associated with the comment
comment.CommentShape.FillFormat.ImageData = ms.ToArray()

'Save the workbook
workbook.Save("e:\test2\commentwithpicture1.xlsx", Aspose.Cells.SaveFormat.Xlsx)

热推产品

  • ActiveReport... 强大的.NET报表设计、浏览、打印、转换控件,可以同时用于WindowsForms谀坔攀戀Forms平台下......
  • AnyChart AnyChart使你可以创建出绚丽的交互式的Flash和HTML5的图表和仪表控件。可以用于仪表盘的创......
首页 | 新闻中心 | 产品中心 | 技术文档 | 友情连接 | 关于磐岩 | 技术支持中心 | 联系我们 | 帮助中心 Copyright-2006 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 电话:023 - 67870900 传真:023 - 67870270 产品咨询:sales@componentcn.com 渝ICP备12000264号 法律顾问:元炳律师事务所 重庆市江北区塔坪36号维丰创意绿苑A座28-5 邮编:400020
在线客服
在线客服系统
在线客服
在线客服系统