aspose 获取Excel中插入的对象
来源:互联网 发布:大学生兼职数据分析 编辑:程序博客网 时间:2024/06/06 13:06
引入using Aspose.Cells;
aspose.cells.dll的下载地址是http://download.csdn.net/detail/keyrainie/4547523
此demo只是讲出取Excel插入附件的原理,代码较简单
private void AsponseTest()
Workbook awork = new Workbook(textBox1.Text);
Worksheet asheet = awork.Worksheets[0];
Workbook awork2 = new Workbook();
Worksheet asheet2 = awork2.Worksheets[0];
try
{
byte[] imageData = null;
byte[] objectData = null;
string sourceFullName = "";
int upperLeftRow = 0;
int upperLeftColumn = 0;
int height = 0;
int width = 0;
bool displayAsIcon = false;
Aspose.Cells.Drawing.OleFileType fileType = Aspose.Cells.Drawing.OleFileType.Xls;
string progID = "";
//循环的去除插入的对象
{
//获取对象属性,为生成新的Excel插入对象使用
imageData = item.ImageData; //对象图标
objectData = item.ObjectData; //对象内同
sourceFullName = item.SourceFullName;
upperLeftRow = item.UpperLeftRow;
upperLeftColumn = item.UpperLeftColumn;
height = item.Height;
width = item.Width;
displayAsIcon = item.DisplayAsIcon;
fileType = item.FileType;
progID = item.ProgID;
asheet2.OleObjects.Add(upperLeftRow, upperLeftColumn, height, width, imageData);
//此功能是读取出一个图片,并另存为
MemoryStream outputImage = new MemoryStream(imageData, 0, (int)imageData.Length);
Image returnImage = Image.FromStream(outputImage);
pictureBox1.Image = returnImage;
File.WriteAllBytes(@"C:\Users\ZhangYu\Desktop\2.txt", objectData);
}
//生成新的Excel,插入附件,此方法暂时只是举例插入一个对象,若需要插入多个对象,则看情况改逻辑就可以
foreach (Aspose.Cells.Drawing.OleObject item in asheet2.OleObjects)
{
item.ObjectData = objectData;
item.SourceFullName = sourceFullName;
item.DisplayAsIcon = displayAsIcon;
item.FileType = fileType;
item.SetNativeSourceFullName(sourceFullName);
item.ProgID = progID;
}
int count = asheet.OleObjects.Count;
awork2.Save(targetPath);
}
catch (Exception ex)
{
}
- aspose 获取Excel中插入的对象
- excel中如何删除一个已经插入的对象(calendar control 9.0)?
- 使用Excel中的插入对象功能在Excel中插入Word文档
- C#向EXCEL中插入图表对象,并设置标题
- 使用Aspose.Pdf从PDF文件中获取个别的附件
- 用Aspose.Words从HTML中插入一个表
- ACAD中插入EXCEL表格的方法
- EXCEL中插入"√"或"×"的处理
- Asp.Net中应用Aspose.Cells输出报表到Excel
- 一个小例子(sql获取刚插入数据库中对象的主键)
- 使用Aspose读取Excel
- 导入excel(Aspose)
- Aspose.Cell 导出Excel
- aspose.excel格式
- Aspose 导出Excel
- excel 中插入文件
- excel中插入文档
- excel 中插入图片
- 流管道
- Delphi中DLL的建立和调用
- Java10个优秀的调试技巧
- MVC 3.0 使用自定义的Html控件
- Windows下删除.svn文件夹的最简易方法
- aspose 获取Excel中插入的对象
- Hadoop命令手册(收集中)
- ssh整合遇到的问题
- 风尘中,忘了捡拾那日女子留下的胭脂
- 什么是NP问题,NP-complete和NP-hard问题.
- 打patch
- delphi一句话帮助
- 【phpcms-v9】使用后台的表单向导做前台的留言板功能
- 浅谈迷途指针