We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Trouble Parsing Images from Cells.Workbook.Worksheets

.NET Aspose.Cells 8.6.0.0

I am having trouble finding the worksheet's images in the worksheet object after loading a document. I have an excel file with images, and post loading to a workbook object, the images just disappear. They dont exists anywhere in the WorkBook object. Can you explain to me how Aspose.Cells populates images from sheets into the object model to be used later? I really only need to persists the excel file and to save as PDF file, however, I'm curious as to the mechanism Aspose.Cells uses to carry the images over. i know that excel stores the images in a folder, but there is no "accessor" in the object to get there or to store the coordinates form what i can see...

I have included a sample excel file, with a single sheet, that contains a single image for you to trouble shoot. I'm truly only trying to load the excel file and save as a PDF maintaining all the attributes and content. I do however in my code save each sheet as its own PDF to avoid memory issues with large workbooks.

Thanks again for your help.
Cary A.

Hi,


Thanks for the template file,

Please try using Worksheet.PictureCollection API to get the images in the worksheet. I have tested the following sample code with your template Excel file, it works fine, I can get the Picture object (having the image) and export to save the image in a file on the disk. Also, when I save the spreadsheet to PDF, the picture is rendered fine in the output PDF file:
e.g
Sample code:

Workbook workbook = new Workbook(“e:\test2\TESTImage.xlsx”);
Worksheet worksheet = workbook.Worksheets[“Sheet1”];
Aspose.Cells.Drawing.Picture pic = worksheet.Pictures[0];
pic.ToImage(“e:\test2\outpic1.png”, new ImageOrPrintOptions() { ImageFormat = ImageFormat.Png });
workbook.Save(“e:\test2\outTESTImage1.pdf”);

Let us know if you still have any issue.

Thank you.
I was able to track the issue to the following setting which prevented the picture collection from being populated.

excelLoadOptions.LoadDataAndFormatting = true;

Hi,


Ok, you got it right. Please do not use or set LoadOptions.LoadDataAndFormatting to true because Aspose.Cells would only load data, formulas and formatting from the Excel file. All other objects, contents
and settings would be discarded. For example: shapes, validation, conditional
formattings, PivotTables won’t be loaded anymore.

Thank you.

Hi,

Thanks for your posting and using Aspose.Cells.

It is good to know that you were able to sort out this issue. Let us know if you encounter any other issue, we will be glad to look into it and help you further.