Free Support Forum - aspose.com

Exporting Pictures

Is there a way to export a Picture as a bitmap like the Chart.ToImage, similar to the images created when using office automation to save the excel file as a HTMl document?

Hi,

You may use Picture.Data property, it will extract the image in bytes of array (binary data).

See the following code below:

Workbook workbook = new Workbook();
workbook.Open("d:\\test\\picbook.xls");
Worksheet worksheet = workbook.Worksheets[0];
Picture pic = worksheet.Pictures[0];
string fileName = "d:\\test\\myimage.Jpg";
FileStream file = File.Create(fileName);
byte[] data = pic.Data;
file.Write(data, 0, data.Length);

Thank you.

Excellent - thanks!

I've got to testing this and can't find the Picture.Data property - also checked the online API (http://www.aspose.com/Products/Aspose.Cells/Api/index.html?url=http://www.aspose.com/Products/Aspose.Cells/Api/Aspose.Cells.PictureMembers.html)

and can't find this property.

Hi,

Please try the attached fix.

We will update the document of Aspose.Cells.